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 /
  • Help Room /
avatar image
2
Question by FutureProg · Apr 30, 2016 at 05:09 PM · assetsave datacustom editorscriptable objecteditor window

Custom Editor Window Not Saving Scriptable Object

Hi there,

I've spent hours trying to figure out why this isn't working (I've followed everything I've seen on the internet as well). I am creating a conversation editor which represents each message, choice, etc. as a node. alt text

After hitting save I can switch between different conversation asset files no problem; It saves the changes to disk. However, after play testing all of my changes are gone (as in, I press play, the game loads the asset, then wipes it). Here's the code I use to load the asset:

ConversationEditor editor = EditorWindow.GetWindow ();
editor.conversation = (Conversation)Selection.activeObject;
editor.activeObject = Selection.activeObject;
editor.saveLocation = AssetDatabase.GetAssetPath (Selection.activeInstanceID);
Undo.RecordObject (editor.conversation, "Edit Conversation");

Here's the code I use to save the asset:

AssetDatabase.Refresh ();
EditorUtility.SetDirty (_conversation);
AssetDatabase.SaveAssets ();

The conversation class extends Scriptable Object. Please help. I'm not sure what to do anymore.

screen-shot-2016-04-30-at-125902-pm.png (34.6 kB)
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

· Add your reply
  • Sort: 
avatar image
1

Answer by Walpeup · May 01, 2016 at 03:51 AM

@FutureProg, I'm not sure if this will solve your problem, but your question solved mine! I was facing the same issue and it was because I wasn't using EditorUtility.SetDirty. I used your method, but had to re-arrange the order of the calls, the following worked for me:

 EditorUtility.SetDirty(assetObject);
 AssetDatabase.SaveAssets ();
 AssetDatabase.Refresh ();

As near as I can tell, the Refresh has to occur at the end to get the editor to re-load the changes that the AssetDatabase just stored.

Comment
Add comment · Show 5 · 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 FutureProg · May 01, 2016 at 03:57 AM 0
Share

Happy to help you out, but sorry, it doesn't work for me.

avatar image Walpeup FutureProg · May 01, 2016 at 04:09 AM 0
Share

Sorry about that, if you want to check out my entire project you might be able to find something that can help. It's on GitHub at https://github.com/TwoTacos/Voxxy/tree/develop , the ScriptableObject is VoxImporter and the saving starts at line 241.

avatar image FutureProg Walpeup · May 01, 2016 at 04:42 PM 0
Share

I'm saving my asset the exact same way that you are. Where is it in the code that you create the VoxImporter asset?

Show more comments

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

54 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

Related Questions

Regarding ScriptableObjects, Inheritance and custom editors 0 Answers

automatically create gameobjects from images in a folder 0 Answers

How to save custom editor data? 0 Answers

Serialize child ScriptableObject asset values in parent ScriptableObject asset. 0 Answers

How to use RenderStaticPreview OR get project viewer thumbnails for ScriptableObject assets? 2 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