Search Unity

Instantiate a template from code?

Discussion in 'UIElements' started by aybe, May 28, 2019.

  1. aybe

    aybe

    Joined:
    May 24, 2015
    Posts:
    99
    Following https://docs.unity3d.com/Manual/UIE-WritingUXMLTemplate.html, I now have my own control but I can't find a way on how to instantiate it from code (would like to instantiate many of them in fact).

    Basically this is what I'm trying to re-use, a control whose color and text can be set:

    2019-05-29_00-45-39.png

    Tried the following:
    • create an Instance, name it and set display: none to hide it
    • query for this TemplateContainer, works fine
    • clone this element ... impossible :(
    How is one supposed to instantiate an arbitrary amount of UXML templates from code?
     
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    61
  3. aybe

    aybe

    Joined:
    May 24, 2015
    Posts:
    99
    Thanks!