diff --git a/Assets/Resources/UI/ARView.prefab b/Assets/Resources/UI/ARView.prefab index 2e37a91..09bd6ae 100644 --- a/Assets/Resources/UI/ARView.prefab +++ b/Assets/Resources/UI/ARView.prefab @@ -289,7 +289,7 @@ GameObject: m_IsActive: 1 --- !u!1 &1461557036225360 GameObject: - m_ObjectHideFlags: 0 + m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 @@ -556,7 +556,7 @@ Transform: - {fileID: 4802536742996532} - {fileID: 4501641520781714} m_Father: {fileID: 224804495073354866} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4501641520781714 Transform: @@ -777,6 +777,7 @@ MonoBehaviour: m_EditorClassIdentifier: DetailsPanel: {fileID: 114451700018395534} ProjectionEffect: {fileID: 114717549802739924} + Crosshairs: {fileID: 1466316426385876} --- !u!114 &114116594606330924 MonoBehaviour: m_ObjectHideFlags: 1 @@ -2222,7 +2223,7 @@ RectTransform: - {fileID: 224757765789199188} - {fileID: 224017865803686938} m_Father: {fileID: 224804495073354866} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2370,8 +2371,9 @@ RectTransform: - {fileID: 224781237586130416} - {fileID: 224060988043194314} - {fileID: 224272151730405692} + - {fileID: 224954540062687134} m_Father: {fileID: 224804495073354866} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -2485,7 +2487,6 @@ RectTransform: m_LocalScale: {x: 0, y: 0, z: 0} m_Children: - {fileID: 224632685815868688} - - {fileID: 224954540062687134} - {fileID: 224620536568054620} - {fileID: 224250538007241578} - {fileID: 4112130633259944} @@ -2638,8 +2639,8 @@ RectTransform: m_Children: - {fileID: 224567183914418614} - {fileID: 224216194665817218} - m_Father: {fileID: 224804495073354866} - m_RootOrder: 1 + m_Father: {fileID: 224620536568054620} + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} diff --git a/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs b/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs index 9f5d938..c660504 100644 --- a/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/UI/ARViewBehaviour.cs @@ -8,6 +8,12 @@ namespace RothenburgAR.UI { public DetailsPanelBehaviour DetailsPanel; public ProjectionEffectBehaviour ProjectionEffect; + public GameObject Crosshairs; + + public void Start() + { + Crosshairs.SetActive(DisplayManager.Instance.AllowCrosshairControls); + } public void DisplayPoiDetails(PoiBehaviour poi, bool animated = true) { diff --git a/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs index e227a40..363ac8f 100644 --- a/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs +++ b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs @@ -18,7 +18,11 @@ namespace RothenburgAR.UI public readonly UnityEvent OnOrientationChange = new UnityEvent(); public ScreenOrientation ScreenOrientation; - private Vector2 resolution; // Current Resolution + + private static readonly float CrosshairControlsDisplaySizeThreshold = 7f; + public bool AllowCrosshairControls { get; private set; } + + private Vector2 lastKnownResolution; // Current Resolution private ScreenOrientation orientation; // Current Screen Orientation static void Init() @@ -35,12 +39,17 @@ namespace RothenburgAR.UI scaler.screenMatchMode = UnityEngine.UI.CanvasScaler.ScreenMatchMode.MatchWidthOrHeight; scaler.matchWidthOrHeight = .5f; - instance.resolution = new Vector2(Screen.width, Screen.height); + instance.lastKnownResolution = new Vector2(Screen.width, Screen.height); instance.orientation = Screen.orientation; - instance.ScreenOrientation = instance.resolution.x < instance.resolution.y + instance.ScreenOrientation = instance.lastKnownResolution.x < instance.lastKnownResolution.y ? ScreenOrientation.Portrait : ScreenOrientation.Landscape; + + // Screen diagonal in logical inches + var diagonalIn = Mathf.Sqrt(Mathf.Pow(Screen.height, 2) + Mathf.Pow(Screen.width, 2)) / Screen.dpi; + Debug.Log("Screen Diagonal is something like " + diagonalIn + " inches."); + instance.AllowCrosshairControls = diagonalIn >= CrosshairControlsDisplaySizeThreshold; } private void Start() @@ -53,12 +62,12 @@ namespace RothenburgAR.UI private void OnRectTransformDimensionsChange() { - if (orientation != Screen.orientation || !(resolution.x == Screen.width && resolution.y == Screen.height)) + if (orientation != Screen.orientation || !(lastKnownResolution.x == Screen.width && lastKnownResolution.y == Screen.height)) { orientation = Screen.orientation; - resolution = new Vector2(Screen.width, Screen.height); - ScreenOrientation = resolution.x < resolution.y - ? ScreenOrientation.Portrait + lastKnownResolution = new Vector2(Screen.width, Screen.height); + ScreenOrientation = lastKnownResolution.x < lastKnownResolution.y + ? ScreenOrientation.Portrait : ScreenOrientation.Landscape; OnOrientationChange.Invoke(); diff --git a/RothenburgAR.apk b/RothenburgAR.apk index 0988300..c60d7a8 100644 Binary files a/RothenburgAR.apk and b/RothenburgAR.apk differ