F
F
Fangahra2015-08-11 16:10:57
Unity
Fangahra, 2015-08-11 16:10:57

It is necessary to test in Unity3d how the program will behave when the phone screen is rotated. How can I do this in the Unity editor itself?

Let's say this code, see below.
No matter how I change the screen resolution in the Game window, it still displays Portrait.
if(Screen.orientation == ScreenOrientation.Portrait)
{
if(Screen.orientation == ScreenOrientation.Portrait)
{
print("P");
}
if(Screen.orientation == ScreenOrientation.PortraitUpsideDown)
{
print("PUD");
}
if(Screen.orientation == ScreenOrientation.Landscape)
{
print("L");
}
if(Screen.orientation == ScreenOrientation.LandscapeRight)
{
print("LR");
}print("P");
if(Screen.orientation == ScreenOrientation.PortraitUpsideDown)
{
print("PUD");
}
if(Screen.orientation == ScreenOrientation.Landscape)
{
print("L");
}
if(Screen.orientation == ScreenOrientation.LandscapeRight)
{
print("LR");
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2015-08-11
@Fangahra

Make a public parameter:
And at the beginning of the footcloth with if, do this:

ScreenOrientation screenOrientation = Application.isEditor ? editorOrientation: Screen.orientation;
if (screenOrientation == ScreenOrientation.Portrait)
{
}

Then you can change the orientation at any time as you want.
You can also try playing around with PlayerSettings.defaultInterfaceOrientation , maybe it updates Screen.orientation at runtime .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question