crosshair controls now only active on devices with screen diagonals > 7"

This commit is contained in:
2019-01-09 22:17:36 +01:00
parent a19e7151d9
commit 45f7f61a5e
4 changed files with 30 additions and 14 deletions

View File

@@ -289,7 +289,7 @@ GameObject:
m_IsActive: 1 m_IsActive: 1
--- !u!1 &1461557036225360 --- !u!1 &1461557036225360
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5 serializedVersion: 5
@@ -556,7 +556,7 @@ Transform:
- {fileID: 4802536742996532} - {fileID: 4802536742996532}
- {fileID: 4501641520781714} - {fileID: 4501641520781714}
m_Father: {fileID: 224804495073354866} m_Father: {fileID: 224804495073354866}
m_RootOrder: 4 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4501641520781714 --- !u!4 &4501641520781714
Transform: Transform:
@@ -777,6 +777,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
DetailsPanel: {fileID: 114451700018395534} DetailsPanel: {fileID: 114451700018395534}
ProjectionEffect: {fileID: 114717549802739924} ProjectionEffect: {fileID: 114717549802739924}
Crosshairs: {fileID: 1466316426385876}
--- !u!114 &114116594606330924 --- !u!114 &114116594606330924
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -2222,7 +2223,7 @@ RectTransform:
- {fileID: 224757765789199188} - {fileID: 224757765789199188}
- {fileID: 224017865803686938} - {fileID: 224017865803686938}
m_Father: {fileID: 224804495073354866} m_Father: {fileID: 224804495073354866}
m_RootOrder: 3 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
@@ -2370,8 +2371,9 @@ RectTransform:
- {fileID: 224781237586130416} - {fileID: 224781237586130416}
- {fileID: 224060988043194314} - {fileID: 224060988043194314}
- {fileID: 224272151730405692} - {fileID: 224272151730405692}
- {fileID: 224954540062687134}
m_Father: {fileID: 224804495073354866} m_Father: {fileID: 224804495073354866}
m_RootOrder: 2 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
@@ -2485,7 +2487,6 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0}
m_Children: m_Children:
- {fileID: 224632685815868688} - {fileID: 224632685815868688}
- {fileID: 224954540062687134}
- {fileID: 224620536568054620} - {fileID: 224620536568054620}
- {fileID: 224250538007241578} - {fileID: 224250538007241578}
- {fileID: 4112130633259944} - {fileID: 4112130633259944}
@@ -2638,8 +2639,8 @@ RectTransform:
m_Children: m_Children:
- {fileID: 224567183914418614} - {fileID: 224567183914418614}
- {fileID: 224216194665817218} - {fileID: 224216194665817218}
m_Father: {fileID: 224804495073354866} m_Father: {fileID: 224620536568054620}
m_RootOrder: 1 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5} m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5} m_AnchorMax: {x: 1, y: 0.5}

View File

@@ -8,6 +8,12 @@ namespace RothenburgAR.UI
{ {
public DetailsPanelBehaviour DetailsPanel; public DetailsPanelBehaviour DetailsPanel;
public ProjectionEffectBehaviour ProjectionEffect; public ProjectionEffectBehaviour ProjectionEffect;
public GameObject Crosshairs;
public void Start()
{
Crosshairs.SetActive(DisplayManager.Instance.AllowCrosshairControls);
}
public void DisplayPoiDetails(PoiBehaviour poi, bool animated = true) public void DisplayPoiDetails(PoiBehaviour poi, bool animated = true)
{ {

View File

@@ -18,7 +18,11 @@ namespace RothenburgAR.UI
public readonly UnityEvent OnOrientationChange = new UnityEvent(); public readonly UnityEvent OnOrientationChange = new UnityEvent();
public ScreenOrientation ScreenOrientation; 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 private ScreenOrientation orientation; // Current Screen Orientation
static void Init() static void Init()
@@ -35,12 +39,17 @@ namespace RothenburgAR.UI
scaler.screenMatchMode = UnityEngine.UI.CanvasScaler.ScreenMatchMode.MatchWidthOrHeight; scaler.screenMatchMode = UnityEngine.UI.CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
scaler.matchWidthOrHeight = .5f; scaler.matchWidthOrHeight = .5f;
instance.resolution = new Vector2(Screen.width, Screen.height); instance.lastKnownResolution = new Vector2(Screen.width, Screen.height);
instance.orientation = Screen.orientation; instance.orientation = Screen.orientation;
instance.ScreenOrientation = instance.resolution.x < instance.resolution.y instance.ScreenOrientation = instance.lastKnownResolution.x < instance.lastKnownResolution.y
? ScreenOrientation.Portrait ? ScreenOrientation.Portrait
: ScreenOrientation.Landscape; : 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() private void Start()
@@ -53,12 +62,12 @@ namespace RothenburgAR.UI
private void OnRectTransformDimensionsChange() 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; orientation = Screen.orientation;
resolution = new Vector2(Screen.width, Screen.height); lastKnownResolution = new Vector2(Screen.width, Screen.height);
ScreenOrientation = resolution.x < resolution.y ScreenOrientation = lastKnownResolution.x < lastKnownResolution.y
? ScreenOrientation.Portrait ? ScreenOrientation.Portrait
: ScreenOrientation.Landscape; : ScreenOrientation.Landscape;
OnOrientationChange.Invoke(); OnOrientationChange.Invoke();

Binary file not shown.