Element 'UnityEngine.UIElements.TextElement' has no registered factory method.

TextElement works in Editor but does not appear to work in a standalone build.

You can reproduce it with a simple UXML:

<?xml version="1.0" encoding="utf-8"?>



It runs fine in Editor but a standalone build results in errors:

If you attempt to access that element from code, it returns null.

So it appears that TextElement is not supposed to be used directly. According to the documentation it’s an abstract class:

I was confused by the fact that it was suggested by my IDE and that it worked in Editor. This might need some clarification in the docs or better yet it should not be present in the main XSD. I will leave this here in case someone else has this problem.

The same error when I try to use TextElement for my build.
But the documentation says that i can use it like a Text Field:

This is a real bug and it has been fixed in the 2021.2 alpha builds. There was no logged issue for it but it got fixed alongside this: Unity Issue Tracker - No registered factory method error is thrown when class that inherit and extend an UIElement is used

3 Likes

I came across the same error on a custom VisualElement I made. In this case it turned out to be a namespace issue.
I was already using my element in an UIDocument when I, during some refactoring, put it in a namespace and BOOM! => “Element ‘CustomVisualElement’ has no registered factory method”!

The fix was to manually update the UIDocument.

So

<CustomVisualElement>
...
</CustomVisualElement>

became

<My.Namespace.CustomVisualElement>
...
</My.Namespace.CustomVisualElement>