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 /
This question was closed Feb 25, 2017 at 03:33 PM by Scoutas for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Scoutas · Feb 24, 2017 at 01:06 AM · editorserializationeditorwindowassetdatabase

Asset variables needs [SerializeField] to be saved when reopening Unity.

Is this the intended behaviour? I've been creating my own custom Editor Windows, with the help of which I edit the ScriptableObject asset.

I do know about the EditorUtility.SetDirty(asset) and I use it every single time the custom editor makes changes, but when I didn't have [SerializeField] attribute in front of the variables (and [System.Serializable] on the class), it just refused to save.

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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Adam-Mechtley · Feb 24, 2017 at 08:16 AM

Yes this is expected. You may find the page in the docs on Script Serialization helpful.

Moreover, it is recommended that your custom editor display these fields using controls with the SerializedProperty class (via the Editor.serializedObject property) rather than directly modifying the field on the inspected target, as SerializedProperty will automatically take care of dirtying, undo/redo, multi-editing, and so on. You can search around this site for more info if you run into issues with it, but the basic pattern is something like this:

 public override void OnInspectorGUI()
 {
     this.serializedObject.Update();
     // your controls here, like e.g., EditorGUILayout.PropertyField(this.serializedObject.FindProperty("someField"));
     this.serializedObject.ApplyModifiedProperties();
 }


Comment
Add comment · Show 1 · 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 Scoutas · Feb 24, 2017 at 04:26 PM 0
Share

Gotcha. Will read up more on all of it, just started messing around with all this recently, got loads to learn. Thank you!

Follow this Question

Answers Answers and Comments

78 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

Related Questions

EditorWindow: How to Serialize variables after PLay 1 Answer

Why does my Unity Serialization not work? Do i miss something? 1 Answer

How do I wait until after AssetDatabase creates an assets before carrying out another function ? 0 Answers

Editor Window Serialization not Working as Expected 2 Answers

Help with Missing Monobehaviours and Asset Serialization? 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