Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Mikilo · Feb 24, 2013 at 11:15 PM · editoreditor-scriptingpropertydrawer

Why PropertyDrawers shared same values?

Hello everyone,

I used PropertyDrawers to automatically display a list of skills on the inspector. So, I have a ListSkillDrawer and a SkillDrawer. SkillDrawer have some values needed to be saved for its own uses, like a popup index (to remember the position in the popup) or a foldout.

The problem is, when I change one of these values, it is saved in the SkillDrawer, then all drawers received the update. So, I can easily assume that drawers are allocated once for all. But what can we do if we want to brake this rule?

In my example, if we have many skills, one foldout will command all skills's foldout.

Does someone have an answer?

I have an idea on how to do my stuff, but it a pretty ugly trick. Here is my explanation. I wrote the ListDrawer, so when I'm calling PropertyField to draw my children, I can send them an iterator by the label. Thus, SkillDrawers will saved popup's index and fold in an array.

Comment
Add comment · Show 1
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 Mikilo · Feb 25, 2013 at 02:39 PM 0
Share

Does someone have an idea?

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Mikilo · Aug 31, 2015 at 02:58 PM

After all this time, never thought to solve this topic since I know now the solution.

There is an unique PropertyDrawer per field. Thus it is shared. End of the story.

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
avatar image
0

Answer by poday · Apr 09, 2013 at 03:22 PM

I found a potential/partial answer, each SerializedProperty has a public isExpanded bool member. This bool has a separate instance for every property, so in theory every property can have it's own separate and independent foldout.

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 Mikilo · Apr 09, 2013 at 03:34 PM 0
Share

Are you saying that if I set isExpanded to true or false, multiple drawers will be allocated? O_o "This bool has a separate instance for every property", I don't really understand this sentence.

avatar image poday · Apr 09, 2013 at 03:41 PM 0
Share

Inside the GetPropertyHeight(SerializedProperty property, GUIContent label) and OnGUI(Rect position, SerializedProperty property, GUIContent label) you're given a SerializedProperty, that SerializedProperty has an isExpanded bool: http://docs.unity3d.com/Documentation/ScriptReference/SerializedProperty-isExpanded.html

You still have the single instance of the Drawer class (and shared instances of the attribute class). That's why I mentioned it as a partial solution, there's a single bool per property that you can use in a foldout.

avatar image Mikilo · Apr 09, 2013 at 03:48 PM 0
Share

Oh.. Ok I see. But my problem wasn't really the foldout problem. That was just a visual problem, an example. The real problem is that my drawers musn't shared data at all.

Since february, I've discovered a new way to search solutions. I use ILSpy and take a look into Unity's DLL. It gives me code of methods.

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

10 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

Related Questions

Why does my custom property drawer's DragAndDrop add items twice? 2 Answers

How to show type text in EditorGUI.ObjectField? 1 Answer

PropertyDrawer let's dissapear my INT 0 Answers

GetPropertyHeight infinite recursion on drawer 1 Answer

CustomPropertyDrawer: foldout issues when switching properties (simulating weak references) 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