I am currently implementing the new UIElements system.
When creating a custom element that uses the factory pattern. The source works just fine. However, when I create a DLL of the assembly I get the following error: “Element ‘type’ has no registered factory method”. Any ideas why this is happening?
The DLL is not created by Unity. And the factory pattern is visible inside a decompiler.
To my understanding, A DLL that is not built by Unity does not strip code (to my understanding).
I have a custom c# solution that gets build separately for this setup.
If your element is in or inherits from an element that is in the UnityEditor.UIElements namespace, this will not be included in any player build (but it will “seem” to work when in playmode inside the Editor). It might be why you see this error.
You’re in uncharted waters, I’m afraid. We have not really tested this use case and, as an advanced use case, it’s not high on our priorities at the moment as we try to ship the toolkit. Not saying it’s not a valid use case, just can’t say when we can officially support it right now.
Some hints from the team point to a potential problem in how we look for assemblies when we try to find the correct element to instantiate when cloning a UXML asset. My suggestion would be to ship a shim text-based assembly on along-side of your dll-based assembly that contains the types you want to instantiate via UXML but just forwards them to the dll-types. Just something to try.
If you do find the solution (or the problem), I’d be curious to know. If it’s something simple we can fix on our end, we might be able to squeeze it in for the next release.