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 /
avatar image
0
Question by Fyrburn · Apr 17, 2021 at 02:49 AM · serializationscriptableobject

An alternative to unstable ScriptableObject?

I have one major problem with ScriptableObject - if I mess around with the code of the scriptable object, I can run the risk of losing data.

For example if I change "public int cost;" to "public int price;", I've now lost the data for the cost entirely for over 200 objects and need to manually re-enter.

In contrast, if I was using XML I could just do a find-replace-all in my text editor for "cost>" to "price>" and everything's just fine.

The catch, unfortunately, is that if I use XML I lose the fairly vital inheritance functionality as XmlSerializer doesn't let me pick and choose which element of the array will be which child class.

Example:

 <animals>
   <animal> name </name>
   <cat> name, age </cat>
   <cat> name, age </cat>
   <pterodactyl> name, age, flightspeed </pterodactyl>
 </animals>

Is there any middle ground that lets me edit data outside of unity in one large file, thus preserving its integrity, while also allowing me to pick and choose which child class will be used in a convenient way?

I suppose the nasty method would be to create scriptable objects that take a text asset as their input and put every individual element in its own xml file but.....urgh. There has to be a better way.

Being able to tell the xml serializer what each array element is would be ideal but failing that is there a happy medium?

Particularly I'd like to avoid too many inidividual files to ensure it doesn't affect load time too much.

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
Best Answer

Answer by dorusoftware · Apr 17, 2021 at 09:39 AM

from my little experince with scriptable objects they may not be the best way to store data espeacially if you have a lot of small objects as you have said, 200 or something.

best to use this asset

https://assetstore.unity.com/packages/tools/integration/simplesql-3845

I've did some test and works great once you got the hang of how all is connected. you can then edit and update a database outside unity with ease in a free third party datase editor.

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 Fyrburn · Apr 18, 2021 at 04:13 AM 0
Share

I'll give that asset a try, thanks! Seems I already picked it up a while ago in a sale, no reason not to tinker then. If not, it's on the right trach that using some kind of external DB does seem like the logical middle ground.

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

122 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

Related Questions

Saving players progress in ScriptableObject asset 1 Answer

Field is member of a type which is serializable but is of type which is not serializable 0 Answers

Abstract classes in a ScriptableObject 1 Answer

Make the same serialized class as a ScriptableObject? 1 Answer

Serializing scriptableobjects array for savegame 1 Answer


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