Search Unity

UIElements uss "name" property

Discussion in 'UIElements' started by LaneFox, Sep 20, 2018.

  1. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,435
    Code (csharp):
    1. VisualElement node = new VisualElement { name = selectorName };
    To reduce ambiguity can the
    name
    property become
    selector
    or
    selectorName
    ? This is the only instance I can think of in Unity during normal workflow where "name" is not the name of the element or component.

    When first being introduced to UIElements and not knowing anything about traditional web development or css this is a bit confusing. It is also a little odd since it is done through a constructor, where "name" would be even more appropriate for naming the element rather than looking up a selector name reference for which to apply properties to the new element.
     
  2. bestbatchprogrammer101

    bestbatchprogrammer101

    Joined:
    Apr 12, 2018
    Posts:
    1
    Hello sir, I have been using Unity for a while so I am quite familiar with the current Editor GUI. But I really want to start using this new UIElements but I have no idea how to start, I could find no examples on the docs and the github page that once housed some examples has been removed. Would you be kind enough to give me an example or point me to a location where I can find something to help me begin? Thank you so much!
     
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,435
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    225
    UIElements is still Experimental as of 18.3. More complete docs and examples will be released alongside UIElements when it comes out of Experimental. The current plan is to do this for the 19.1 Unity release. The UIElements API is still expected to change.

    But back on the topic of this thread, "name" is not really equivalent to "selector". A selector can be based on the name, but it can also be based on the C# type of the element or the style classes it has on it. Name is equivalent to the "id" on the web. It's meant to be used much like GameObject names to more easily find the element, both for styling (selectors) and within C# using uQuery to register events on it.
     
  5. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    97
    FYI, we now have a dedicated sub-forums where you can use for all your questions and feedback related to UI Systems Previews.

    Cheers,
     
    LaneFox likes this.