Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextField in flex-row

Discussion in 'UI Toolkit' started by wang37921, Jan 25, 2019.

  1. wang37921

    wang37921

    Joined:
    Aug 1, 2014
    Posts:
    102
    upload_2019-1-25_16-58-24.png
    upload_2019-1-25_17-5-17.png
    uxml:
    <ui:VisualElement>
    <ui:Label></ui:Label>
    <ui:TextField></ui:TextField>
    </ui:VisualElement>

    uss:
    VisualElement{
    flex-direction: row;
    }
    Label{
    flex-shrink:0;
    flex-grow:0.1;
    flex-basis:100;
    }
    TextField{
    flex-grow:1;
    }

    Question:
    while input in the TextField, it will growth.
    How to setting, avoid it?
    Better keep the grow while resize the window.
     
  2. Rocktavious

    Rocktavious

    Joined:
    May 10, 2017
    Posts:
    44
  3. jeanfrancois_unity

    jeanfrancois_unity

    Unity Technologies

    Joined:
    Oct 24, 2018
    Posts:
    4
    @Cong37921
    Just make sure the VisualElement is also having flex-grow and flex-shrink set to 0
    If you put the VisualElement from your example in a parent with the "flex-direction : column" and flex-grow and flex-shrink = 0 it should work like you want.

    Also, note that in 19.1, the TextField will also contain an optional label so the construction you made above won't be necessary.