diff --git a/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs b/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs index 129dc06..c4d329e 100644 --- a/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/UI/DetailsPanelBehaviour.cs @@ -48,7 +48,12 @@ namespace RothenburgAR.UI ? transform.offsetMax.y : initialHeight; - if (Screen.orientation == ScreenOrientation.Portrait) + Debug.Log(String.Format("Recalculating DetailsPanel position. Orientation: [{1}x{2}]{0}\n", + Screen.orientation.ToString(), + Screen.currentResolution.width, + Screen.currentResolution.height)); + + if (DisplayManager.Instance.ScreenOrientation == ScreenOrientation.Portrait) { // stretch horizontally transform.anchorMax = new Vector2(1, 0); diff --git a/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs index afcac2c..e227a40 100644 --- a/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs +++ b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs @@ -16,10 +16,10 @@ namespace RothenburgAR.UI } } - public readonly UnityEvent OnResolutionChange = new UnityEvent(); public readonly UnityEvent OnOrientationChange = new UnityEvent(); - Vector2 resolution; // Current Resolution - ScreenOrientation orientation; // Current Screen Orientation + public ScreenOrientation ScreenOrientation; + private Vector2 resolution; // Current Resolution + private ScreenOrientation orientation; // Current Screen Orientation static void Init() { @@ -37,6 +37,10 @@ namespace RothenburgAR.UI instance.resolution = new Vector2(Screen.width, Screen.height); instance.orientation = Screen.orientation; + + instance.ScreenOrientation = instance.resolution.x < instance.resolution.y + ? ScreenOrientation.Portrait + : ScreenOrientation.Landscape; } private void Start() @@ -49,49 +53,16 @@ namespace RothenburgAR.UI private void OnRectTransformDimensionsChange() { - // Check for an orientation change. - ScreenOrientation curOri = Screen.orientation; - switch (curOri) - { - case ScreenOrientation.Unknown: // Ignore - { - break; - } - default: - { - if (orientation != curOri) - { - orientation = curOri; - OnOrientationChange.Invoke(); - } - break; - } - } - - // Check for a resolution change. - if ((resolution.x != Screen.width && resolution.x != Screen.height) || (resolution.y != Screen.height && resolution.y != Screen.width)) + if (orientation != Screen.orientation || !(resolution.x == Screen.width && resolution.y == Screen.height)) { + orientation = Screen.orientation; resolution = new Vector2(Screen.width, Screen.height); - OnResolutionChange.Invoke(); - } + ScreenOrientation = resolution.x < resolution.y + ? ScreenOrientation.Portrait + : ScreenOrientation.Landscape; -#if UNITY_EDITOR - else - { - // PC doesn't have device orientation, so do this for testing purposes OnOrientationChange.Invoke(); } -#endif - } - - public void AddResolutionChangeListener(UnityAction callback) - { - OnResolutionChange.AddListener(callback); - } - - public void RemoveResolutionChangeListener(UnityAction callback) - { - OnResolutionChange.RemoveListener(callback); } public void AddOrientationChangeListener(UnityAction callback) @@ -109,7 +80,6 @@ namespace RothenburgAR.UI if (instance == this) { // Clean up memory. - OnResolutionChange.RemoveAllListeners(); OnOrientationChange.RemoveAllListeners(); instance = null; } diff --git a/Assets/RothenburgAR/Scripts/UI/TrackableEventHandler.cs b/Assets/RothenburgAR/Scripts/UI/TrackableEventHandler.cs index c257cee..191d740 100644 --- a/Assets/RothenburgAR/Scripts/UI/TrackableEventHandler.cs +++ b/Assets/RothenburgAR/Scripts/UI/TrackableEventHandler.cs @@ -39,8 +39,7 @@ namespace RothenburgAR.UI if (previousStatus == TrackableBehaviour.Status.TRACKED && newStatus == TrackableBehaviour.Status.NOT_FOUND) { var poi = UIManager.Instance.ARViewBehaviour.ProjectionEffect.SelectedPOI; - if ( - UIManager.Instance.ARViewBehaviour.DetailsPanel.gameObject.activeInHierarchy && poi != null) + if (UIManager.Instance.ARViewBehaviour.DetailsPanel.gameObject.activeInHierarchy && poi != null) { if (poi.GetComponent().Exhibit == Exhibit) { diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 2ee515f..1b05f94 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -160,6 +160,7 @@ PlayerSettings: applicationIdentifier: Android: de.fhws.rothenburgar Standalone: de.fhws.rothenburgar + iOS: de.fhws.rothenburgar buildNumber: {} AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 16 @@ -276,6 +277,8 @@ PlayerSettings: m_Enabled: 1 - m_BuildTarget: Standalone m_Enabled: 1 + - m_BuildTarget: iOS + m_Enabled: 1 openGLRequireES31: 0 openGLRequireES31AEP: 0 m_TemplateCustomTags: {}