- Home /
Adjust UI, On Device Orientation Change
Hello again!
I think the title is fairly clear and you know what I want to achieve. I just want to know if there is simple way, or some kind of "best practice"?
By the way I am using the 4.6 Beta (new GUI).
Thank you in advance!
Head's up, the new GUI system is called UI to distinguish it from its predecessor.
Interesting question, though. I would think in most situations you could merely stretch and / or rotate the canvas, and the anchoring system would compensate for having been stretched / turned. If you can't do it to the canvas itself, then insert a parent object (child of canvas, parent of canvas elements) and alter that ins$$anonymous$$d.
I've found that, typically, ux differs between portrait and landscape so drastically that you might as well use two discrete canvases which are switched on and off depending on which orientation you are in. This doesn't necessarily apply to the simplest of cases where you might be able to get away with simply rotating the canvas. As @AlwaysSunny suggests, the Anchoring system should accommodate it, and provided you've setup your RectTransforms correctly then it should appear serviceable.
Answer by vakanderson · Feb 20, 2015 at 06:17 PM
The anchoring system handles most situations like the other posters noted, however some interfaces can/should be laid out quite differently for various orientations. For those cases, once you know the orientation has changed, you can use the animation system or custom scripting to re-arrange the elements on screen. Here's how to detect the change:
http://docs.unity3d.com/Manual/MobileAdvanced.html
"You can retrieve device orientation by accessing the Screen.orientation property."
actually http://docs.unity3d.com/460/Documentation/Manual/MobileAdvanced.html