Search Unity

Regarding runtime UI elements and referencing it

Discussion in 'UIElements' started by RealMTG, Sep 4, 2019.

  1. RealMTG


    Jul 27, 2013

    I'm just very curious about the new runtime UI elements and how it will work with "applying" the UXML and USS. Like, right now, when you want to load a file you have to use AssetDatabase or something like Resources.Load, which in my opinion, is horrible. Hardcoded paths should not be mandatory. So at runtime, can we reference these UXML and USS files on a component of some sort to load them instead of using coded paths?
    To me, this is quite the dealbreaker. Without a way to directly reference these files, this feature will be useless to me when it comes to assets because I want to my third party assets into a "Imported" folder.

    Thanks, and I'm really looking forward to the new system! :)
  2. uDamian


    Unity Technologies

    Dec 11, 2017
    Just to give you an idea of the approach we're taking, there will be a Panel Component you add to a GameObject that will have parameters to assign a uxml asset and 0 or more uss assets. This link would therefore be done in the scene and work at runtime without hard-coded paths.

    This Panel Component would have a root VisualElement, just like EditorWindow does now, where it will clone the uxml and to which you have full access to the entire UI hierarchy.
    Kirsche and RealMTG like this.