Search Unity

How to change the size of Controls (TextField's input box in particular)

Discussion in 'UI Toolkit' started by JennyHide, Jun 8, 2019.

  1. JennyHide

    JennyHide

    Joined:
    Sep 30, 2014
    Posts:
    47
    Hello,

    I'm testing the GraphView API and added a TextField to my test node. The label takes up loads of space while the input box is squashed onto the end:

    upload_2019-6-8_19-3-18.png

    How can I change the default width of both boxes?

    Looking at the code (https://github.com/Unity-Technologi...0796/Modules/UIElements/Controls/TextField.cs) I assumed it'd be with USS, adding a new class to the "visualInput" variable, but visualInput is not accessible. Is there another way?

    Also, is there a way to set the maximum size of the input box - the default behaviour is for the box to get bigger the more text I add into it.

    Thanks,
    Jenny
     
  2. JennyHide

    JennyHide

    Joined:
    Sep 30, 2014
    Posts:
    47
    I worked it out - I just needed to override the appropriate USS classes in my own USS script!
     
  3. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    @JennyHide Where did you find the appropriate USS classes to override? I'm trying to find the names of the classes in GraphView.uss but can't find them on GitHub, etc.
     
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Best is to use the UIElements Debugger and simply inspect the elements you want to change or imitate styles for/from. You can find the Debugger under Window > Analysis > UIElements Debugger
     
    kimyir2, JessicaSkye and Marble like this.