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 /
This question was closed Feb 17, 2021 at 12:16 PM by mak431020.
avatar image
0
Question by mak431020 · Feb 06, 2021 at 07:35 AM · scriptableobjectbinaryformatter

How to serialize a scriptable object ?

How to Serialize this so i can save it in binary formatter

 [CreateAssetMenu(menuName = "Item", fileName = "New Item")]
  public class Item : ScriptableObject
  {
      public string itemName;
      public int itemPrice;
      public Sprite itemSprite;
  }










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

2 Replies

  • Sort: 
avatar image
0

Answer by logicandchaos · Feb 06, 2021 at 02:05 PM

Scriptable objects are serialized. Actually everything that shows up in the unity inspector is serialized, it has to be for unity to view it.

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 AbandonedCrypt · Feb 06, 2021 at 03:08 PM 0
Share

Not really, they're serializable. That's why scriptableobject data does not persist between edit and play mode (unity serializing and deserializing everything) if you don't specifically a) set them dirty, or b) save them explicitly.

avatar image logicandchaos AbandonedCrypt · Feb 06, 2021 at 03:37 PM 0
Share

but it does persist between edit and play mode, there are videos all about using scriptable object architecture based on that attribute. I work a lot with scriptable objects and all the data persists for me between edit and play mode.

avatar image AbandonedCrypt logicandchaos · Feb 06, 2021 at 03:38 PM 0
Share

You don't seem to have read my comment.

avatar image
0

Answer by AbandonedCrypt · Feb 06, 2021 at 03:14 PM

ScriptableObject do not have to be serialized with any serialization tool. The good thing about ScriptableObjects is that they can natively be saved as .asset files (Note: when using CreateAssetMenu tag, these are automatically saved in your Assets and you don't need to go through the following steps)

You can use AssetDatabase.CreateAsset(Object ob, String path); to save a SO in your assets. You can use AssetDatabase.LoadAssetAtPath() to load your ScriptableObject asset at Editor time.

At runtime you can use whatever your preferred resource retrieval method is.

If you want your SO data to persist, you can use EditorUtility.SetDirty() or AssetDatabase.SaveAssets()

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

Follow this Question

Answers Answers and Comments

115 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

Related Questions

How to Serialize Scriptable Object at Runtime? 1 Answer

How can I find all instances of a Scriptable Object in the Project (Editor) 3 Answers

Are ScriptableObjects good for non-visualised models? 2 Answers

[Custom Editor] MonoBehaviour vs Scriptable Object 0 Answers

How to share a script between multiple gameobjects but with different values 3 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