Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
5
Question by Antonio_Elizio · Apr 25, 2019 at 03:46 AM · c#custom editorcustom-inspectorcustom inspectorcustom-editor

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.

uxml:

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

alt text
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);
         });

alt text


In the documentation does not have any use example .

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

anotacao-2019-04-25-002518.png (1.9 kB)
anotacao-2019-04-25-004303.png (2.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by LeXuSMalus · Feb 21, 2020 at 04:11 PM

Just use full assembly name.

  <uie:ObjectField name="Texture2D" type="UnityEngine.Texture2D, UnityEngine.CoreModule" binding-path="icone" label="Object" allow-scene-objects="false"/>
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image merpheus · Feb 21, 2020 at 04:35 PM 0
Share

Interesting! Gotta try it.

avatar image paulstraw · Jul 21, 2020 at 01:34 AM 0
Share

Future readers: Note that this functionality was added in Unity 2020.1b, as seen in the "Release notes" section of this page:

UI Elements: Added type attribute to ObjectField UX$$anonymous$$L attributes. This allows you to specify a type and associated Assembly. For example "[sic]. If you are unsure of the type string to use, you can use typeof($$anonymous$$yType).AssemblyQualifiedName to get the full string.

avatar image bodowens paulstraw · Dec 05, 2020 at 10:31 AM 0
Share

I have this UX$$anonymous$$L element: <editor:ObjectField type="UnityEngine.TextAsset, UnityEngine.Core$$anonymous$$odule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" label="File"/> I have also tried: <editor:ObjectField objectType="UnityEngine.TextAsset, UnityEngine.Core$$anonymous$$odule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" label="File"/> They both produce the same thing the OP has.

avatar image
3

Answer by merpheus · Jul 14, 2019 at 12:49 AM

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);


Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mikevargas · Aug 18, 2019 at 12:48 PM 0
Share

The documentation seriously needs to be updated to reflect this.

avatar image stektpotet · Mar 31, 2020 at 03:43 PM 1
Share

This is not true, at least not any more. You can specify the type for it using the assembly qualified name of the type.

essentially using the full string you'll get when doing

 typeof(Texture2D).AssemblyQualifiedName

$$anonymous$$y reccomendation is to just do

 Debug.Log(typeof(Texture2D).AssemblyQualifiedName);

and copy the printout into your uxml ObjectField, in it's type-attribute.

avatar image bodowens stektpotet · Dec 05, 2020 at 10:28 AM 0
Share

I have the same issue with TextAsset. Tried "UnityEngine.TextAsset", "UnityEngine.TextAsset, UnityEngine.Core$$anonymous$$odule" and "UnityEngine.TextAsset, UnityEngine.Core$$anonymous$$odule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" (i.e. output of typeof(TextAsset).AssemblyQualifiedName). I tried all of them with both "type" and "objectType" atrributes and none of it works.

avatar image
1

Answer by DarkGate · Aug 01, 2020 at 08:38 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

177 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Objects in Custom Editor Resetting on Play 1 Answer

ApplyModifiedProperties() ignored on nested serialized property w custom editor and custom property drawer 2 Answers

Custom Editor: Array of Structs with elements hidden by toggles 0 Answers

ArgumentException: Getting control 19's position in a group with only 19 controls when doing dragPerform Aborting 0 Answers

Unity Custom Editor: 1 True Bool Only Within A Group 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges