I have 2d game in landscape mode. I'd like to introduce switching from landscape to portrait anf vice versa.
The UI looks fine in editor in portrait mode (I just resize main control node in scene)
But when I run the game on mobile and switch from landscape to portrait with
if (current == DisplayServer.ScreenOrientation.Landscape ||
current == DisplayServer.ScreenOrientation.ReverseLandscape)
{
DisplayServer.ScreenSetOrientation(DisplayServer.ScreenOrientation.Portrait);
}
else
{
DisplayServer.ScreenSetOrientation(DisplayServer.ScreenOrientation.Landscape);
}
(Or just DisplayServer.WindowSetSize(new Vector2I(720, 1280)); for desktop) -
The actual scale(?) is off, so th UI is clearly different from how it looks in editor.
What happens if you start with the portrait mode? Not by switching it to portrait mode, but actually adjusting and saving the MainMenu size to be 720x1280 when you start the game.
Is it still off, or fine then?
When I actually set 720x1280 portrait in settings and set the scene as 720*1280 - everythings fine for portrait mode, but now the landscape mode is not properly scaled(
This way the UI in game really is the same as in editor. But as the tooltip says - it doesn’t really fit games, as setting the mode to disabled brought more chaos to the the gameplay scenes than it did good to UI scenes.
The tip about designing in a square actually works, but I believe only for UI, as I had to set the WxH in settings to like 1000x1000 and again - it still gives a nuances to the non UI scenes, but still surprisingly better than a Stretch Mode → Disabled