Second version of DetailsPanel rework
improved layout text now scrolls to top on beginning models are now children of their camera to simplify getting a good view of them increased render texture resolution and used a better blending function
This commit is contained in:
@@ -10,6 +10,7 @@ namespace RothenburgAR
|
||||
public class AppInitializerBehaviour : MonoBehaviour
|
||||
{
|
||||
public Camera UICamera;
|
||||
public Camera UIObjectCamera;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
@@ -20,7 +21,8 @@ namespace RothenburgAR
|
||||
VuforiaARController.Instance.RegisterVuforiaInitializedCallback(InitializeData);
|
||||
|
||||
UIManager.Instance.Initialize();
|
||||
UIManager.Instance.SetUiCamera(UICamera);
|
||||
UIManager.Instance.UICamera = UICamera;
|
||||
UIManager.Instance.UIObjectCamera = UIObjectCamera;
|
||||
UIManager.Instance.InitStartView();
|
||||
|
||||
InputManager.Instance.Initialize();
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace RothenburgAR.UI
|
||||
public class DetailsPanelBehaviour : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI DetailsText;
|
||||
public ScrollRect DetailsTextScrollRect;
|
||||
public DetailsModelBehaviour DetailsModel;
|
||||
|
||||
private void Start()
|
||||
@@ -33,27 +34,21 @@ namespace RothenburgAR.UI
|
||||
public void SetText(String el)
|
||||
{
|
||||
DetailsText.text = el;
|
||||
SetBoxHeight();
|
||||
|
||||
// Scroll to top
|
||||
DetailsTextScrollRect.normalizedPosition = new Vector2(0, 1);
|
||||
}
|
||||
|
||||
public void SetModel(GameObject modelGo)
|
||||
{
|
||||
RemoveModel();
|
||||
modelGo.transform.SetParent(DetailsModel.transform, false);
|
||||
|
||||
|
||||
// Apply rotation to the object
|
||||
//var animator = modelGo.AddComponent<Animator>();
|
||||
//animator.runtimeAnimatorController = Resources.Load("UI/InfoModelAnimatorController") as RuntimeAnimatorController;
|
||||
//animator.speed = 0.3f;
|
||||
//animator.Play("poi_model_rotation");
|
||||
|
||||
modelGo.transform.SetParent(UIManager.Instance.UIObjectCamera.transform, false);
|
||||
modelGo.transform.localPosition += new Vector3(0, 0, 450);
|
||||
|
||||
_currentDisplayedModelGo = modelGo;
|
||||
DetailsModel.CurrentModel = _currentDisplayedModelGo;
|
||||
|
||||
DetailsModel.gameObject.SetActive(true);
|
||||
SetBoxHeight();
|
||||
}
|
||||
|
||||
public void SetModelFromPoi(PoiData data)
|
||||
@@ -63,25 +58,13 @@ namespace RothenburgAR.UI
|
||||
{
|
||||
SetModel(data.InstantiateModelPrefab());
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
// ignore, just do not display an object
|
||||
_currentDisplayedModelGo = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBoxHeight()
|
||||
{
|
||||
var rt = GetComponent<RectTransform>();
|
||||
var modelHeight = 0.0f;
|
||||
|
||||
if (HasModel)
|
||||
modelHeight = DetailsModel.GetComponent<LayoutElement>().minHeight;
|
||||
|
||||
var height = Math.Max(120, DetailsText.preferredHeight + modelHeight);
|
||||
rt.sizeDelta = new Vector2(rt.sizeDelta.x, height);
|
||||
}
|
||||
|
||||
|
||||
public void RemoveModel()
|
||||
{
|
||||
DetailsModel.gameObject.SetActive(false);
|
||||
@@ -91,7 +74,6 @@ namespace RothenburgAR.UI
|
||||
Destroy(_currentDisplayedModelGo);
|
||||
_currentDisplayedModelGo = null;
|
||||
}
|
||||
SetBoxHeight();
|
||||
}
|
||||
|
||||
public void UpdateOpeningAnimation(Vector3 position)
|
||||
@@ -157,5 +139,10 @@ namespace RothenburgAR.UI
|
||||
{
|
||||
DetailsModel.EndRotateModelByDrag(data as PointerEventData);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
RemoveModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,8 @@ namespace RothenburgAR.UI
|
||||
public class UIManager : Singleton<UIManager>
|
||||
{
|
||||
private ARViewBehaviour _ARViewBehaviour;
|
||||
private Camera _uiCamera;
|
||||
public Camera UICamera;
|
||||
public Camera UIObjectCamera;
|
||||
|
||||
public Boolean IsARViewVisible
|
||||
{
|
||||
@@ -160,7 +161,7 @@ namespace RothenburgAR.UI
|
||||
Canvas c = _currentViewInstance.GetComponentInChildren<Canvas>();
|
||||
if (c != null)
|
||||
{
|
||||
c.worldCamera = _uiCamera;
|
||||
c.worldCamera = UICamera;
|
||||
c.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
c.planeDistance = 0.5f;
|
||||
}
|
||||
@@ -184,10 +185,5 @@ namespace RothenburgAR.UI
|
||||
_currentView.OnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetUiCamera(Camera uiCamera)
|
||||
{
|
||||
_uiCamera = uiCamera;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user