diff --git a/Assets/Resources/UI/ARView.prefab b/Assets/Resources/UI/ARView.prefab index c54e30c..3b3b460 100644 --- a/Assets/Resources/UI/ARView.prefab +++ b/Assets/Resources/UI/ARView.prefab @@ -2082,8 +2082,8 @@ RectTransform: m_Father: {fileID: 224620536568054620} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.48000002, y: 0.48} - m_AnchorMax: {x: 0.52000004, y: 0.52} + m_AnchorMin: {x: 0.47, y: 0.47} + m_AnchorMax: {x: 0.53, y: 0.53} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} @@ -2161,8 +2161,8 @@ RectTransform: m_Father: {fileID: 224781237586130416} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.4, y: 0.4} - m_AnchorMax: {x: 0.6, y: 0.6} + m_AnchorMin: {x: 0.1, y: 0.1} + m_AnchorMax: {x: 0.9, y: 0.9} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} diff --git a/Assets/RothenburgAR/Animations/Reticule/ReticuleFillAnimation.anim b/Assets/RothenburgAR/Animations/Reticule/ReticuleFillAnimation.anim index 6c0fb04..e8f786b 100644 --- a/Assets/RothenburgAR/Animations/Reticule/ReticuleFillAnimation.anim +++ b/Assets/RothenburgAR/Animations/Reticule/ReticuleFillAnimation.anim @@ -14,52 +14,27 @@ AnimationClip: m_CompressedRotationCurves: [] m_EulerCurves: [] m_PositionCurves: [] - m_ScaleCurves: [] - m_FloatCurves: + m_ScaleCurves: - curve: serializedVersion: 2 m_Curve: - serializedVersion: 2 time: 0 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 - serializedVersion: 2 time: 1 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 0.5, y: 0.5, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x path: Mask - classID: 224 - script: {fileID: 0} - - curve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 2 - time: 0 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - - serializedVersion: 2 - time: 1 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: m_SizeDelta.y - path: Mask - classID: 224 - script: {fileID: 0} + m_FloatCurves: [] m_PPtrCurves: [] m_SampleRate: 60 m_WrapMode: 0 @@ -70,16 +45,9 @@ AnimationClip: genericBindings: - serializedVersion: 2 path: 3747441678 - attribute: 1967290853 + attribute: 3 script: {fileID: 0} - typeID: 224 - customType: 0 - isPPtrCurve: 0 - - serializedVersion: 2 - path: 3747441678 - attribute: 38095219 - script: {fileID: 0} - typeID: 224 + typeID: 4 customType: 0 isPPtrCurve: 0 pptrCurveMapping: [] @@ -109,20 +77,20 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x + attribute: m_LocalScale.x path: Mask classID: 224 script: {fileID: 0} @@ -131,20 +99,42 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.y + attribute: m_LocalScale.y + path: Mask + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z path: Mask classID: 224 script: {fileID: 0} diff --git a/Assets/RothenburgAR/Animations/Reticule/ReticuleFilled.anim b/Assets/RothenburgAR/Animations/Reticule/ReticuleFilled.anim index 9155c59..5865202 100644 --- a/Assets/RothenburgAR/Animations/Reticule/ReticuleFilled.anim +++ b/Assets/RothenburgAR/Animations/Reticule/ReticuleFilled.anim @@ -14,52 +14,27 @@ AnimationClip: m_CompressedRotationCurves: [] m_EulerCurves: [] m_PositionCurves: [] - m_ScaleCurves: [] - m_FloatCurves: + m_ScaleCurves: - curve: serializedVersion: 2 m_Curve: - serializedVersion: 2 time: 0 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 0.5, y: 0.5, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 - serializedVersion: 2 time: 1 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 0.5, y: 0.5, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x path: Mask - classID: 224 - script: {fileID: 0} - - curve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 2 - time: 0 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - - serializedVersion: 2 - time: 1 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: m_SizeDelta.y - path: Mask - classID: 224 - script: {fileID: 0} + m_FloatCurves: [] m_PPtrCurves: [] m_SampleRate: 60 m_WrapMode: 0 @@ -70,16 +45,9 @@ AnimationClip: genericBindings: - serializedVersion: 2 path: 3747441678 - attribute: 1967290853 + attribute: 3 script: {fileID: 0} - typeID: 224 - customType: 0 - isPPtrCurve: 0 - - serializedVersion: 2 - path: 3747441678 - attribute: 38095219 - script: {fileID: 0} - typeID: 224 + typeID: 4 customType: 0 isPPtrCurve: 0 pptrCurveMapping: [] @@ -109,20 +77,20 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x + attribute: m_LocalScale.x path: Mask classID: 224 script: {fileID: 0} @@ -131,20 +99,42 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.y + attribute: m_LocalScale.y + path: Mask + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z path: Mask classID: 224 script: {fileID: 0} diff --git a/Assets/RothenburgAR/Animations/Reticule/ReticuleHollow.anim b/Assets/RothenburgAR/Animations/Reticule/ReticuleHollow.anim index e8d2258..5fffc9a 100644 --- a/Assets/RothenburgAR/Animations/Reticule/ReticuleHollow.anim +++ b/Assets/RothenburgAR/Animations/Reticule/ReticuleHollow.anim @@ -14,52 +14,27 @@ AnimationClip: m_CompressedRotationCurves: [] m_EulerCurves: [] m_PositionCurves: [] - m_ScaleCurves: [] - m_FloatCurves: + m_ScaleCurves: - curve: serializedVersion: 2 m_Curve: - serializedVersion: 2 time: 0 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 - serializedVersion: 2 time: 1 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x path: Mask - classID: 224 - script: {fileID: 0} - - curve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 2 - time: 0 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - - serializedVersion: 2 - time: 1 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: m_SizeDelta.y - path: Mask - classID: 224 - script: {fileID: 0} + m_FloatCurves: [] m_PPtrCurves: [] m_SampleRate: 60 m_WrapMode: 0 @@ -70,16 +45,9 @@ AnimationClip: genericBindings: - serializedVersion: 2 path: 3747441678 - attribute: 1967290853 + attribute: 3 script: {fileID: 0} - typeID: 224 - customType: 0 - isPPtrCurve: 0 - - serializedVersion: 2 - path: 3747441678 - attribute: 38095219 - script: {fileID: 0} - typeID: 224 + typeID: 4 customType: 0 isPPtrCurve: 0 pptrCurveMapping: [] @@ -109,20 +77,20 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x + attribute: m_LocalScale.x path: Mask classID: 224 script: {fileID: 0} @@ -131,20 +99,42 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.y + attribute: m_LocalScale.y + path: Mask + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z path: Mask classID: 224 script: {fileID: 0} diff --git a/Assets/RothenburgAR/Animations/Reticule/ReticuleHollowAnimation.anim b/Assets/RothenburgAR/Animations/Reticule/ReticuleHollowAnimation.anim index 756da95..7d1bfb9 100644 --- a/Assets/RothenburgAR/Animations/Reticule/ReticuleHollowAnimation.anim +++ b/Assets/RothenburgAR/Animations/Reticule/ReticuleHollowAnimation.anim @@ -14,52 +14,27 @@ AnimationClip: m_CompressedRotationCurves: [] m_EulerCurves: [] m_PositionCurves: [] - m_ScaleCurves: [] - m_FloatCurves: + m_ScaleCurves: - curve: serializedVersion: 2 m_Curve: - serializedVersion: 2 time: 0 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 0.5, y: 0.5, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 - serializedVersion: 2 time: 1 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x path: Mask - classID: 224 - script: {fileID: 0} - - curve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 2 - time: 0 - value: 16 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - - serializedVersion: 2 - time: 1 - value: 32 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: m_SizeDelta.y - path: Mask - classID: 224 - script: {fileID: 0} + m_FloatCurves: [] m_PPtrCurves: [] m_SampleRate: 60 m_WrapMode: 0 @@ -70,16 +45,9 @@ AnimationClip: genericBindings: - serializedVersion: 2 path: 3747441678 - attribute: 1967290853 + attribute: 3 script: {fileID: 0} - typeID: 224 - customType: 0 - isPPtrCurve: 0 - - serializedVersion: 2 - path: 3747441678 - attribute: 38095219 - script: {fileID: 0} - typeID: 224 + typeID: 4 customType: 0 isPPtrCurve: 0 pptrCurveMapping: [] @@ -109,20 +77,20 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.x + attribute: m_LocalScale.x path: Mask classID: 224 script: {fileID: 0} @@ -131,20 +99,42 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: 16 + value: 0.5 inSlope: 0 outSlope: 0 tangentMode: 136 - serializedVersion: 2 time: 1 - value: 32 + value: 1 inSlope: 0 outSlope: 0 tangentMode: 136 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_SizeDelta.y + attribute: m_LocalScale.y + path: Mask + classID: 224 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z path: Mask classID: 224 script: {fileID: 0} diff --git a/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs new file mode 100644 index 0000000..46b1b79 --- /dev/null +++ b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs @@ -0,0 +1,104 @@ +using UnityEngine; +using UnityEngine.Events; + +namespace RothenburgAR.UI +{ + [RequireComponent(typeof(RectTransform))] + public class DisplayManager : MonoBehaviour + { + static DisplayManager instance = null; + public static DisplayManager Instance + { + get + { + Init(); + return instance; + } + } + + public readonly UnityEvent OnResolutionChange = new UnityEvent(); + public readonly UnityEvent OnOrientationChange = new UnityEvent(); + Vector2 resolution; // Current Resolution + ScreenOrientation orientation; // Current Screen Orientation + + static void Init() + { + if (instance != null) return; + GameObject canvas = new GameObject("DisplayManager"); + canvas.AddComponent().renderMode = RenderMode.ScreenSpaceOverlay; + instance = canvas.AddComponent(); + DontDestroyOnLoad(canvas); + + instance.resolution = new Vector2(Screen.width, Screen.height); + instance.orientation = Screen.orientation; + } + + private void Start() + { + if (instance != this) + { + Destroy(this); + } + } + + 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)) + { + resolution = new Vector2(Screen.width, Screen.height); + OnResolutionChange.Invoke(); + } + } + + public void AddResolutionChangeListener(UnityAction callback) + { + OnResolutionChange.AddListener(callback); + } + + public void RemoveResolutionChangeListener(UnityAction callback) + { + OnResolutionChange.RemoveListener(callback); + } + + public void AddOrientationChangeListener(UnityAction callback) + { + OnOrientationChange.AddListener(callback); + } + + public void RemoveOrientationChangeListener(UnityAction callback) + { + OnOrientationChange.RemoveListener(callback); + } + + private void OnDestroy() + { + if (instance == this) + { + // Clean up memory. + OnResolutionChange.RemoveAllListeners(); + OnOrientationChange.RemoveAllListeners(); + instance = null; + } + } + } +} \ No newline at end of file diff --git a/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs.meta b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs.meta new file mode 100644 index 0000000..69549b3 --- /dev/null +++ b/Assets/RothenburgAR/Scripts/UI/DisplayManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: de73ecce4589a9f4ab11cf5a7dc54d8a +timeCreated: 1536164178 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/RothenburgAR/Scripts/UI/PercentualPaddingBehaviour.cs b/Assets/RothenburgAR/Scripts/UI/PercentualPaddingBehaviour.cs index 7f3a94c..8be828e 100644 --- a/Assets/RothenburgAR/Scripts/UI/PercentualPaddingBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/UI/PercentualPaddingBehaviour.cs @@ -12,6 +12,19 @@ namespace RothenburgAR.UI public float Padding = 0.01f; void Start() + { + DisplayManager.Instance.OnOrientationChange.AddListener(RecalculateTransform); + DisplayManager.Instance.OnResolutionChange.AddListener(RecalculateTransform); + RecalculateTransform(); + } + + void OnDestroy() + { + DisplayManager.Instance.OnOrientationChange.RemoveListener(RecalculateTransform); + DisplayManager.Instance.OnResolutionChange.RemoveListener(RecalculateTransform); + } + + public void RecalculateTransform() { var transform = this.GetComponent(); float desiredPadding = Mathf.Max(Screen.height, Screen.width) * Padding; @@ -27,11 +40,5 @@ namespace RothenburgAR.UI if (transform.anchorMin.y <= 0.01f) transform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, desiredPadding, size); if (transform.anchorMin.x <= 0.01f) transform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, desiredPadding, size); } - - // Update is called once per frame - void Update() - { - - } } } \ No newline at end of file diff --git a/Assets/updaterScene.unity b/Assets/updaterScene.unity index 16ce66b..52a610f 100644 --- a/Assets/updaterScene.unity +++ b/Assets/updaterScene.unity @@ -480,7 +480,7 @@ GameObject: - component: {fileID: 289788188} - component: {fileID: 289788187} m_Layer: 0 - m_Name: ScriptContainer + m_Name: UpdaterBehaviour m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0