Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity UI Avoid UI reshape on orientation change, or force native system orientation

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Dragonic89, Oct 18, 2017.

  1. Dragonic89


    Jan 3, 2013

    Working on my small personal project I'm trying to figure out how to implement the best Portrait <=> Landscape system/transition.

    The anchoring system in unity is really useful, but in my context it's not enought because I really need some specific changes that I can't control with only the default UI system. A basic example is below for an expected result :

    There is the exact same number of elements between this portrait and landscape example, but as you can see elements on the red panel are all centered in landscape mode. And there is some changes in element positions in the red and the blue panel (inverted).

    With the default Unity system and no script, I can only have at best this result in landscape mode, with the previous portrait example as default model :

    This is really far from the first expected result ^^ !

    Ok, no problem I locked the orientation on Portrait, added a listener to find when the orientation change, and created the script to rotate and translate the right objects in order to get the expected result. It's not really difficult and I don't have to manipulate the panels or their anchors manually. The result is currently visually perfect, and I even have some tween animations for each transition.

    But here is the problem : when I click in landscape mode on a InputField, the system keyboard open in portait mode :( !

    Well, I should have expected this ^^ ! So here I am wondering what can be the best solution in a generic way ?

    - first, is there a way to force the system keyboard (and maybe any other native system) to open in a specific orientation, even with a locked orientation in my Unity project settings ?

    - on the contrary, can I unlock the orientation system but force the UI to not be reshaped by the Unity system on each orientation change, so I can manually apply my changes ?

    - if not, what is the best ? Unlock the orientation system and manually reshape, replace, change anchors, ...., on stricly every gameobject for each orientation even if this will take some time ? Or maybe create a specific gameobject with child objects for portrait mode, and another one with child objects for landscape mode, and activate the right one for each orientation (this will mean some redundancy) ? ...

    One of the two first options would be really useful if possible, and I need some advices to figure the best answer ^^ !
    Last edited: Oct 18, 2017
  2. Brogan89


    Jul 10, 2014
    I have tried to tackle this issue too. I have created my own tool you could try out here
    or there is also this asset.
  3. Dragonic89


    Jan 3, 2013
    Thank you, I will look at that now !