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
2
Question by Patyrn · May 25, 2011 at 10:42 PM · databasestorage

Best way to store\retrieve simple textual data?

For example, in an RPG you might want to store a list of weapons, with their various attributes, names of their models and textures, etc. What is the preferred way of accomplishing this in unity?

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

Answer by Ray-Pendergraph · May 26, 2011 at 09:10 PM

We do a lot of this in XML (System.Xml). Most of the missions on our games have models (domain models not 3D models) of at least one kind or another and the System.Xml stuff is very easy to use and bind to your model classes to feed your game. To store the data you can also put the XML files in asset bundles (as text assets) and slurp them off the disk or across the wire using the WWW class and parse the text bytes in the game. You can build them into the game by putting them into a folder in the project name "Resources" and use the Resources.Load to pull them in. This makes the data baked into the game at build time though as opposed to having the ability to get new configurations via the asset bundle functionality.

I am not a huge XML advocate but it is the most supported common interchange format. I would love to attempt YAML or JSON to write the configuration files as XML is so verbose. Most of those libraries are open source and we have not had a chance to test them out since some of them look to be unmaintained. We have not noticed any significant overhead but we keep the parsing to specific parts of the game... you don't want to parse it 'during' the game.

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 Patyrn · May 26, 2011 at 11:02 PM 2
Share

The X$$anonymous$$L file in Resources definitely seems the best option for hard-coded data storage. $$anonymous$$y problem now is storing player state data that is more complex than PlayerPrefs seems suited for. I think serializing\deserializing some kind of PlayerState class will be the way to go there, but I've yet to figure out how that works.

avatar image Ray-Pendergraph · May 26, 2011 at 11:20 PM 2
Share

On various platforms (particulary the Windows and $$anonymous$$ac standalone) you can use System.IO to persist the same type of models with just regular IO. I have done this to persist various game states. Depending on what platform you are on standard IO packages may or may be accommodated. Check out the Application object to see what paths might be available. http://unity3d.com/support/documentation/ScriptReference/Application.html

avatar image Patyrn · May 26, 2011 at 11:21 PM 2
Share

Could you define the definition of "model" you're using? Not knowing is confusing me. :)

avatar image Ray-Pendergraph · May 26, 2011 at 11:36 PM 2
Share

$$anonymous$$odel as in domain model (http://en.wikipedia.org/wiki/Domain_model) which represents the data like user data, game state, inventory, score, damage, etc. You can use attributes from the X$$anonymous$$L namespace (System.Xml) to easily annotate the model classes that represent these things in the game and save them out to disk and even persist them remotely on a server to a database or service. On some Unity platforms particularly the desktop platforms (Winblows and $$anonymous$$ac) you can use standard C# file IO to pretty much do anything you want with persisting data to the disk (encrypt them, whatever). The mobile platforms probably differ at least a little.

avatar image Patyrn · May 27, 2011 at 12:00 AM 1
Share

Thanks for the help. It is much appreciated.

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

2 People are following this question.

avatar image avatar image

Related Questions

How to store profile data in unity with firebase 0 Answers

Where to store data about location 0 Answers

Store item images in database or on device? 0 Answers

Custom Editor Window to Create and Store Item Data 1 Answer

Data Storage 5 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