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
1
Question by D3Duck · Nov 09, 2018 at 11:41 PM · savingassetdatabasecustomeditor

Why is ScriptableObject asset not saving to disk?

I have these nested classes that I want to save:

 [CreateAssetMenu(order = 0)]
 [System.Serializable]
 public class Quest : ScriptableObject
 {
     public string name;
     public string description;
     
     [SerializeField] List<QuestSection> sections;
 }

 [System.Serializable]
 public class QuestSection
 {
     public string name;
     public string description;
     
     [SerializeField] List<QuestObjective> objectives;
 }

 [System.Serializable]
 public class QuestObjective
 {
     public string name;
     public string description;
 }

I made an editor window to edit it after creation and save in disable or when a button in the editor is pressed:

 public void Save()
 {
     if(AssetDatabase.Contains(currentQuest)) //The quest being edited
     {
         AssetDatabase.SetDirty(currentQuest);
         AssetDatabase.Refresh();
         AssetDatabase.SaveAssets();
     }
 }

The name and description of the Quest class are still there after unity restart. The list empties out.

I've set the classes and variables to serialize, I've used various combinations and sequences of SetDirty(), Refresh(), and SaveAssets() but none have worked. Each time I close the editor and open again, the asset is still there, but has an empty list (which I can see in the inspector before even opening my custom editor window so this is not the problem). While the editor is open everything is fine, so it seems to be a save-to-disk problem. I've gone through many forum threads which only give the above answers. Any directions would be appreciated.

Edit: Tried making this work using the Serialized object functions. No luck

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 D3Duck · Nov 10, 2018 at 10:19 PM 0
Share

Bump. Any ideas welcome on this.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hectorux · Nov 10, 2018 at 12:20 AM

Is an error with custom editor, if you copy the component values after setting up your things in the inspector, and then paste them, it will work (2018.3.4b)

Comment
Add comment · Show 2 · 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 D3Duck · Nov 10, 2018 at 01:26 AM 0
Share
 Is an error with custom editor

You mean a Unity bug?

I tried copying and pasting values but not sure what you mean by that. I set all my values in the inspector window as opposed to custom editor and still didn't save to disk.

avatar image hectorux D3Duck · Nov 10, 2018 at 01:51 AM 0
Share

it worked for me, sorry

avatar image
0

Answer by Matt1000 · Nov 10, 2018 at 10:45 PM

Have you actually tried applying those to the ScriptableObject?

 currentQuest.SetDirty();
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 D3Duck · Nov 10, 2018 at 11:10 PM 0
Share

Does that work in a custom editor window? CurrentQuest is just an instance of the Quest class referring to the ScriptableObject being edited. I did try the Apply$$anonymous$$odifiedProperties() etc which didn't do anything. I'll check as soon as I get home.

Edit: Didn't work sadly. Also gives deprecated warning and says to use AssetDatabase.SetDirty()

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

96 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

Related Questions

Calling all Assetdatabase experts 0 Answers

How are unity references serialized? (instanceID related) 1 Answer

Manually Saving ScriptableObject due to 2D Array... 0 Answers

Scriptable Object not saving changes to a list. 0 Answers

it is Playerprefs can use in saving highscore and both PC having this can same see data in Highscores? 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