diff --git a/Assets/Resources/UI/ARView.prefab b/Assets/Resources/UI/ARView.prefab index 59c6694..9ca4373 100644 --- a/Assets/Resources/UI/ARView.prefab +++ b/Assets/Resources/UI/ARView.prefab @@ -149,7 +149,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!1 &1365754499144302 GameObject: m_ObjectHideFlags: 1 @@ -1360,7 +1360,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 114013157313467306} m_HandleRect: {fileID: 224126681634059420} m_Direction: 2 - m_Value: 0.49999982 + m_Value: 0.49999964 m_Size: 0.7254501 m_NumberOfSteps: 0 m_OnValueChanged: @@ -2152,8 +2152,8 @@ RectTransform: m_Father: {fileID: 224251385334151864} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 0.1372749} + m_AnchorMax: {x: 1, y: 0.862725} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 20, y: 20} m_Pivot: {x: 0.5, y: 0.5} @@ -2251,7 +2251,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: -0.000015258789} - m_SizeDelta: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 166.52002} m_Pivot: {x: 0.5, y: 0.5} --- !u!224 &224272151730405692 RectTransform: diff --git a/Assets/RothenburgAR/Scripts/Exhibition/ExhibitTitleBehaviour.cs b/Assets/RothenburgAR/Scripts/Exhibition/ExhibitTitleBehaviour.cs index 1dd0160..5dda423 100644 --- a/Assets/RothenburgAR/Scripts/Exhibition/ExhibitTitleBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/Exhibition/ExhibitTitleBehaviour.cs @@ -57,7 +57,6 @@ namespace RothenburgAR.Exhibition { GuiText.GetComponent().enabled = false; GuiText.GetComponent().enabled = true; - //StartCoroutine(CreateBorder()); } public void SetDescription(TextElement newDescription) @@ -101,49 +100,5 @@ namespace RothenburgAR.Exhibition } _descriptionPoiData.Description = newDescription; } - - private IEnumerator CreateBorder() - { - yield return null; // wait for next frame so the borderContainer layouter has time to recalculate - - var oldBorder = Background.GetComponentInChildren(); - if (oldBorder != null) Destroy(oldBorder.gameObject); - - var borderContainer = new GameObject("BorderContainer"); - borderContainer.transform.SetParent(Background.transform, false); - - var outlineRenderer = borderContainer.AddComponent(); - outlineRenderer.useWorldSpace = false; - outlineRenderer.startWidth = 0.01f; - outlineRenderer.endWidth = 0.01f; - - Vector3[] corners = new Vector3[4]; - Background.GetComponent().GetLocalCorners(corners); - - //produces weird seam at begin/end point, so we'll loop it ourselves by drawing back to topLeft and topRight manually - outlineRenderer.loop = false; - - Vector3 topLeft = corners[1]; - Vector3 topRight = corners[2]; - Vector3 bottomLeft = corners[0]; - Vector3 bottomRight = corners[3]; - outlineRenderer.positionCount = 9; - outlineRenderer.SetPosition(0, topLeft); - outlineRenderer.SetPosition(1, topRight); - outlineRenderer.SetPosition(2, bottomRight); - outlineRenderer.SetPosition(3, bottomLeft); - outlineRenderer.SetPosition(4, topLeft); - outlineRenderer.SetPosition(5, bottomLeft); - outlineRenderer.SetPosition(6, bottomRight); - outlineRenderer.SetPosition(7, topRight); - outlineRenderer.SetPosition(8, topLeft); - - outlineRenderer.numCornerVertices = 2; - outlineRenderer.numCapVertices = 1; - - outlineRenderer.alignment = LineAlignment.Local; - outlineRenderer.material = UIColorSchemeManager.Instance.GetUIMaterial(UIMaterial.BaseOpaque); - outlineRenderer.enabled = GuiText.GetComponent().enabled; - } } } \ No newline at end of file diff --git a/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs b/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs index af8534f..9f5d938 100644 --- a/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs @@ -1,5 +1,6 @@ using UnityEngine; using RothenburgAR.PointOfInterest; +using System.Collections; namespace RothenburgAR.UI { @@ -8,7 +9,7 @@ namespace RothenburgAR.UI public DetailsPanelBehaviour DetailsPanel; public ProjectionEffectBehaviour ProjectionEffect; - public void DisplayPoiDetails(PoiBehaviour poi) + public void DisplayPoiDetails(PoiBehaviour poi, bool animated = true) { // if POI has no Details to display, do nothing if (!PoiDataManager.Instance.HasPoiData(poi.ReferencedID)) return; @@ -28,14 +29,17 @@ namespace RothenburgAR.UI DetailsPanel.DisplayModelButton(data); - DetailsPanel.UpdateOpeningAnimation(poi.transform.position); + if (animated) + { + DetailsPanel.UpdateOpeningAnimation(poi.transform.position); + } poi.SetActive(true); ProjectionEffect.SelectedPOI = poi.gameObject; ProjectionEffect.SetActive(true); } - + public void HidePoiDetails() { DetailsPanel.gameObject.SetActive(false); diff --git a/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs b/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs index aac8f15..129dc06 100644 --- a/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs @@ -22,7 +22,6 @@ namespace RothenburgAR.UI private void Start() { - gameObject.SetActive(false); DisplayManager.Instance.AddOrientationChangeListener(SetSize); } diff --git a/Assets/RothenburgAR/Scripts/UI/FullscreenModelViewBehaviour.cs b/Assets/RothenburgAR/Scripts/UI/FullscreenModelViewBehaviour.cs index d95db5c..676e82f 100644 --- a/Assets/RothenburgAR/Scripts/UI/FullscreenModelViewBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/UI/FullscreenModelViewBehaviour.cs @@ -3,6 +3,7 @@ using RothenburgAR.PointOfInterest; using System.Collections; using System; using UnityEngine.EventSystems; +using System.Linq; namespace RothenburgAR.UI { @@ -13,11 +14,46 @@ namespace RothenburgAR.UI public GameObject Icon3D; private GameObject _currentDisplayedModelGo; + private PoiData currentPoiData; + + public new void SwitchToARView() + { + UIManager.Instance.SwitchToView(ViewName.ARView); + var arViewBehaviour = UIManager.Instance.ARViewBehaviour; + + // Find poi and corresponding tracker + var trackables = Vuforia.TrackerManager.Instance.GetStateManager().GetTrackableBehaviours().ToList(); + PoiBehaviour poiBehaviour = null; + Vuforia.TrackableBehaviour trackable = null; + foreach (var t in trackables) + { + var pois = t.GetComponentsInChildren().ToList(); + if (pois.Count == 0) continue; + + poiBehaviour = pois.FirstOrDefault(p => p.ReferencedID == currentPoiData.ID); + if (poiBehaviour != null) + { + trackable = t; + break; + } + } + + // Display Poi Details if poi was found + if (poiBehaviour == null) return; + arViewBehaviour.DisplayPoiDetails(poiBehaviour, false); + + // Disable Projection Effect if poi is not currently in view + if (trackable.CurrentStatus != Vuforia.TrackableBehaviour.Status.TRACKED) + { + arViewBehaviour.ProjectionEffect.gameObject.SetActive(false); + } + } public void SetModelFromPoi(PoiData data) { if (!data.HasModelDescription) return; + this.currentPoiData = data; StartCoroutine("SetModelCoroutine", data); }