Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 vbJack · Jan 31, 2020 at 10:24 PM · erroreditorserializedpropertyserializedobjectbrush

Serialized Property being uneditable in certain cases

I'm extending the gridBrush, and the gridBrushEditor to show more information for the user when handling a brush.

I've ran into a weird problem where any created serialized object that is instantiated within the gridBrushEditor would have its serialized properties be uneditable.
basically editable == false.
However, the gridbrusheditor holds a serializedObject reference to the gridBrush. And any serialized property that is used in it actually is editable.
Why is there such a difference between the two?
All of the property fields were set up using the following:

                     GUI.enabled = true;
                     EditorGUI.BeginChangeCheck();
 
                     using (var iter = serializedObject.GetIterator())
                     {
                         iter.Next(true);
                         while (iter.NextVisible(false))
                         {
                             Debug.Log(iter.name + " editable: " + iter.editable);
                             EditorGUILayout.PropertyField(iter, true);
                         }
                     }
 
                     if (EditorGUI.EndChangeCheck())
                     {
                         Debug.Log("Change is happening");
                     }
 
                     serializedObject.ApplyModifiedProperties();

serializedObject would change based on the case, but all of them get printed that way. within the OnSelectionInspectorGUI() method within the editor


Case 1: All values set up as part of the editor

     [Serializable]
     public class CustomData
     {
         public int testI;
         public float testII;
     }
 
     [CustomEditor(typeof(CustomBrush))]
     public class CustomBrushEditor : GridBrushEditor
     {
         public CustomData data;
         public int test2;
     }

In this case, the serialized object is set up using

 new SerializedObject(this)

where this is the CustomBrushEditor.
Result : All serialized properties end up being uneditable.


Case 2: The data is part of a 3rd party UnityObject, this example being a Singleton Scriptable Object.

     [Serializable]
     public class CustomData : ScriptableSingleton<CustomData>
     {
         public int testI;
         public float testII;
     }

In this case the serialized object is setup using

 new SerializedObject(CustomData.Instance)

Obviously being the instance of the data. Result: all serialized properties are uneditable


Case 3: The data is set up as part of the brush which is what the editor is set to be an editor for

     public class CustomBrush : GridBrush
     {
         public int test;
         public CustomData test2;
     }
     
     [Serializable]
     public class CustomData // or can be extended of an SO: ScriptableSingleton<CustomData>
     {
         public int testI;
         public float testII;
     }

In this instance, I would be using the serialized object that is provided by the grid brush editor, which is a reference to the custom grid brush by default. as it is its editor after all.
Result: Be it just a serializeable class, or a scriptable singleton, the serialized property is always editable.


I couldn't find anything about why this is occuring, so i'd appreciate it if someone can show me why exactly this happens.

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

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

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

Related Questions

How do you actually use CanEditMultipleObjects 1 Answer

Get UnityEvent reference from SerializedProperty 1 Answer

Null SerializedProperty SerializedObject upon Removal from list 1 Answer

Triggering updates in a custom EditorWindow 0 Answers

Editor: How to do PropertyField for List elements? 4 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