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

UIElements: engine or ui?

Discussion in 'UI Toolkit' started by ReadyPlayGames, Dec 26, 2018.

  1. ReadyPlayGames

    ReadyPlayGames

    Joined:
    Jan 24, 2015
    Posts:
    49
    Going through the UIElements Developer's Guide, I have noticed some differences between the github examples and those listed in the "guide". Such as...

    Examples:
    <UXML xmlns:ui="UnityEngine.Experimental.UIElements">
    <ui:Label text="This container has no tooltip but its children do"/>

    Guide:
    <engine:UXML xmlns:engine="UnityEngine.Experimental.UIElements">
    <engine:Label text="Select something to remove from your suitcase:"/>

    Which should we use? "engine" or "ui"? Are they different somehow?
     
    Last edited: Dec 26, 2018
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    No they represent the same thing, which is a prefix for a namespace in the document.
    You can read about this here: https://en.wikipedia.org/wiki/XML_namespace

    A good approach is to also assign a default namespace:

    Code (CSharp):
    1.  
    2. <UXML xmlns="UnityEngine.Experimental.UIElements">
    3.     <Label text="This container has no tooltip but its children do"/>
    4. </UXML>
    5.  
    This makes it unnecessary to use a prefix for builtin elements. Our examples should be upgraded to that.
     
    satchell and AndrewKaninchen like this.
  3. ReadyPlayGames

    ReadyPlayGames

    Joined:
    Jan 24, 2015
    Posts:
    49
    Ah, thank you. I'm going to change code to that as well. Unless I can submit changes to your examples? It's always nice to help out!
     
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    We don't have a process in place yet to accept changes. But thank you! We are working on better examples which will have more consistent UXML namespaces.