No type in ObjectField created in uxml (UIElements)

When i create an ObjectField inside the uxml file it appears in the inspector with no type.


<uie:ObjectField name="Texture2D" binding-path="icone" label="Object" allow-scene-objects="false"/>


What I did to work around this problem is to change the type via code:

 root.Query<ObjectField>("Texture2D").ForEach((obj) => {
            obj.objectType = typeof(Texture2D);


In the documentation does not have any use example .

How can i add the type in a ObjectField by uxml?

Just use full assembly name.

 <uie:ObjectField name="Texture2D" type="UnityEngine.Texture2D, UnityEngine.CoreModule" binding-path="icone" label="Object" allow-scene-objects="false"/>

You can’t. You need to poke it through C#. Such as follows:

var uxmlField = container.Q<ObjectField>("the-uxml-field");
uxmlField.type = typeof(YourType);

Seems like the field has been changed from type to objectType.

Type处填写UnityEngine.Texture2D,他会自动补全为UnityEngine.Texture2D, UnityEngine.CoreModule