Fixed screen rotation issue with DetailsPanel
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<PoiBehaviour>().Exhibit == Exhibit)
|
||||
{
|
||||
|
||||
@@ -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: {}
|
||||
|
||||
Reference in New Issue
Block a user