implemented first version of responsive ARView
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
104
Assets/RothenburgAR/Scripts/UI/DisplayManager.cs
Normal file
104
Assets/RothenburgAR/Scripts/UI/DisplayManager.cs
Normal file
@@ -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<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
instance = canvas.AddComponent<DisplayManager>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/RothenburgAR/Scripts/UI/DisplayManager.cs.meta
Normal file
13
Assets/RothenburgAR/Scripts/UI/DisplayManager.cs.meta
Normal file
@@ -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:
|
||||
@@ -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<RectTransform>();
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user