Search Unity

Managing UI for vertical mode and horizontal mode

Discussion in 'UGUI & TextMesh Pro' started by JYKeith, Sep 3, 2014.

  1. JYKeith

    JYKeith

    Joined:
    Aug 17, 2014
    Posts:
    12
    I'm managing UI elements with prefabs to avoid modifying scene information which makes me crazy...
    It works well so far with 4.6 unity UI system :)

    Now, I'm thinking of managing UI for vertical mode and horizontal mode..

    maybe all the things I should do is resetting RectTransform of the objects which have differenct position, size or anchor on each mode.
    but transform of Component class, is for just read, not for modify..

    Is it possible...
    make UI prefabs for each orientation, and initialize the UI gameobject with the prefabs without destroying it?? ,, Can I?

    or Replacing only data of RectTransform, not replacing the whole instance... (not removecomponent and addcomponent)..

    hmm.. Is there any nice idea?? please give me wisdoms~!
     
    Last edited: Sep 3, 2014
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    You can set the anchormin and max positions of a button component for example and then you can set the position relative to those.
     
    Last edited: Sep 3, 2014
  3. JYKeith

    JYKeith

    Joined:
    Aug 17, 2014
    Posts:
    12
    I would like to make specific layout for each mode.. new anchor min, max, pivot ... and position.
    And want to make it easy..
     
  4. PeteD

    PeteD

    Joined:
    Jul 30, 2013
    Posts:
    71
    Can't you simply check the orientation of the device (assuming mobile) and execute the correct canvas/panel based on that?

    In my experience a layout that works in landscape may not always work very well in portrait or on a phone as opposed to a tablet. The correct solution in such a case is to have seperate layouts for each mode.