-
I’ve created visual element in builder and name it MyCustomVisualElement.uxml
-
I’ve created C# control for this
[UxmlElement]
public partial class MyCustomVisualElement : VisualElement
{
public MyCustomVisualElement()
{
}
}
- Now I just want to create this from code like this:
MyCustomVisualElement myCustomVisualElement= new MyCustomVisualElement();
listView.hierarchy.Add(myCustomVisualElement);
I am expecting that uxml template from builder will be created and linked with control automatically because it has THE SAME NAME. But its not, so maybe I have to add some tag in uxml so Unity will understand that
Important note: I don’t want to use Resources.Load(“MyCustomVisualElement”) inside the custom controller constructor. This is a dealbreaker for me. If Unity with all its power can’t handle the link between uxml and customControl automaticaly, I am not going to use UI Elements. Thanks