I’m trying to learn how to work with the Template and Instance tags.
However, I can not achieve the behavior in which it works.
If I post the Template tag after Instance, I’ll get an error
<UXML xmlns:ui="UnityEngine.Experimental.UIElements">
<ui:VisualElement>
<ui:Instance template="myTemplate" />
</ui:VisualElement>
<ui:Template path="myTemplate" name="myTemplate">
<ui:VisualElement name="item">
<ui:Button name="item-button" text="Item"/>
</ui:VisualElement>
</ui:Template>
</UXML>
Error:
Semantic - Unknown template name 'myTemplate'
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[ ], String[ ], String[ ], String[ ], String[ ])
If teplate tag before instance:
Could not resolve template with name 'myTemplate'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I also tried to save the template in a separate file in ‘Resources’ folder. If you ‘forget’ to remove the code from the main file, the errors completely disappear, but nothing happens. If you delete the template from the main file, there will be an error.
Semantic - Unknown template name 'myTemplate'
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[ ], String[ ], String[ ], String[ ], String[ ])
Unity 2019. What am I doing wrong?