Question by
Gluxable · Mar 07, 2019 at 09:26 AM ·
crashorientationblackscreen
Orientation change black screen (android)
When changing the screen orientation the screen goes black and the app crashes. However if I start the app from another specific scene or load this other specific scene the app does not crash on orientation change. What could be causing this? Here is my code.
public void OnRectTransformDimensionsChange()
{
if (Screen.orientation == ScreenOrientation.Portrait || Screen.orientation == ScreenOrientation.PortraitUpsideDown)
SetPortrait();
else if (Screen.orientation == ScreenOrientation.LandscapeRight || Screen.orientation == ScreenOrientation.LandscapeLeft)
SetLandscape();
}
public void SetPortrait()
{
speedGaugesAnim.SetLayerWeight(1, 1);
mapAnim.SetLayerWeight(1, 1);
drawerPortrait.SetActive(true);
menuPortrait.SetActive(true);
drawerLandscape.SetActive(false);
menuLandscape.SetActive(false);
}
public void SetLandscape()
{
speedGaugesAnim.SetLayerWeight(1, 0);
mapAnim.SetLayerWeight(1, 0);
drawerPortrait.SetActive(false);
menuPortrait.SetActive(false);
drawerLandscape.SetActive(true);
menuLandscape.SetActive(true);
}
Comment