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 /
avatar image
0
Question by MacDx · Jun 06, 2019 at 09:53 PM · editor-scriptingeditorwindowenumserializedobjectbinding

UIElements EnumField data binding

Hi! I'm currently making a custom editor window using the new UIElements API. Unfortunately there is not a lot of content right now to do research on this topic and the Unity documentation it's still a bit vague on some specific topics. So I'm hoping I can find someone here who has encountered this issue as well.


The problem I have is that I'm trying to bind an Enum, that is contained inside a scriptable object, to an EnumField (The one that ends up inheriting from VisualElement).


The documentation says that I have to create a SerializedObject out of my ScriptableObject and then bind that either to a parent VisualElement of the EnumField, or to the field itself using the Bind method. So that's what I did but I'm getting this warning and I find it a bit weird.

Field type UnityEditor.UIElements.EnumField is not compatible with Enum property "area"


How is my Enum property not compatible with EnumField? The weird thing is that I also have a TextField binded to a string property (on the same ScriptableObject of course) and that works just fine.


Here's the code that I'm using:

 //Binding code -----------------------------------
 
 //nodeData is an object of my custom type that derives from ScriptableObject
 var so = new SerializedObject(nodeData);
 propertyFieldsContainer.Bind(so); //Code line that issues the warning
 
 stringField.value = so.FindProperty("id").stringValue; //Works as expected
 
 //The enum field draws correctly (with the default value of the enum) but it is unresponsive  
 areaField.value = (MapArea) so.FindProperty("area").enumValueIndex;
 
 //Scriptable Object code ------------------------
 //It just contains these 2 members
 public string id;
 public MapArea area; //MapArea is the enum type


I also tried binding with the field itself but it is the same result. Is this a bug or am I doing something wrong? Please, someone help me!


Edit: Forgot to mention. Before the binding code I'm correctly assigning the bindingPath of those two property fields, so that is not the problem.

Comment
Add comment · Show 2
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 MacDx · Jun 11, 2019 at 05:09 PM 0
Share

alt text

warning.png (4.9 kB)
avatar image MacDx · Jun 13, 2019 at 09:09 PM 0
Share

Turns out, support for binding EnumField to custom enums just got introduced in Unity 2019.3 (alpha version) and I'm working on v 2019.1 so that's why this fails. I filed a bug, and seems like it will be added to 2019.1 and 2019.2.

You can read about it in this forum post:

https://forum.unity.com/threads/enumfield-is-not-compatible-with-enum-property.692767/

0 Replies

· Add your reply
  • Sort: 

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

118 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

Related Questions

Enum Value Changing At Runtime On A Prefab 1 Answer

SerializedProperty and PropertyField NullReference 1 Answer

EditorWindow not working when defined in .net/mono Assembly. 2 Answers

EditorWindow loses Texture2D reference on scene change: how to handle? 4 Answers

Thumbnails from assets in an EditorWindow 0 Answers


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