Not sure what I’m doing wrong.
using UnityEngine;
using UnityEngine.UIElements;
public class CustomElement : VisualElement
{
// this doesn't work either
//public new class UxmlFactory : UxmlFactory<CustomElement, UxmlTraits> { }
public new class UxmlFactory : UxmlFactory<CustomElement> { }
public CustomElement()
{
Debug.Log(this);
}
}
<UXML
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="UnityEngine.UIElements"
xsi:noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd"
xsi:schemaLocation="UnityEngine.UIElements ../UIElementsSchema/UnityEngine.UIElements.xsd">
<Style src="MainMenu.uss" />
<CustomElement>
<Label text="Custom Element Label" />
</CustomElement>
</UXML>```
the error:
Element ‘UnityEngine.UIElements.CustomElement’ has no registered factory method.
UnityEngine.UIElements.UIDocument:OnEnable () (at Library/PackageCache/com.unity.ui@1.0.0-preview.14/GameObjects/UIDocument.cs:315)