• 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 Richard 16 · May 05, 2011 at 09:12 PM · databasexmlstatestorage

Best approach for storing complex data structures and tables (iOS and WebPlayer)

Hello All,

More of an advice request than a straight question. I'm working on a branching narrative implementation for an adventure style game and have started looking for the best way to store the data.

I have:

NPC Dialog, Items, Collectables, Scenes and so forth all of which interlink. This would seem to lend itself to a traditional normalised database design, however I'm not sure how best to proceed..?

So far I've considered:

1) Have a web connection to a SQLServer database. Not too keen on this as it forces a web connection.

2) Use an embedded database such as SQLLite. Not too keen on this as it wont work on iOS (without a whole lot of work) and the web player wont read static files or allow me to ship additional plugin DLLs.

3) Use XML to store the data and (possibly) some kind of Linq -> XML to query.

Does anyone have any thoughts on this? Has any one implemented something similar?

Thanks in advance as always for any help.

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

· Add your reply
  • Sort: 
avatar image
1

Answer by loramaru · May 06, 2011 at 03:05 AM

Let me preface by saying, I've not done WebPlayer or iOS Unity work.

Have you considered using ScriptableObjects? You could make classes for each type of data you want to store and then just make assets for each instance you need. This way you don't have to deal with parsing the data into a format that can be used by your code since it already is. You also have you data in first-class assets and gain all the built-in Unity support for assets, including only including the ones that your scene actually references. You can also interlink directly from asset to asset (no need for name or id references).

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
avatar image
0

Answer by 1337GameDev · Feb 13, 2013 at 05:14 AM

I think the XML would work, and is easily expandable. You could also implement some kind of hash table (to retrieve objects quickly) once the file is local.

If the data is on an external server, can't you just download it to the local client and then access the file? You could the have unity read in the file into a hash table.

The only downside to hash tables is when you get over half full of elements (as more collisions and iterations occur), and when the hash table needs to be resized. Otherwise a hash table is super efficient on retrieving data. So in this case, just store the data into a hash table (which is most cpu intensive part of the procedure) and then retrieve the information during runtime.

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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How can I save a xml file but the data will be coming from a Input Field? 1 Answer

Storing data in Unity as you would in a database 0 Answers

Best way to display long texts 0 Answers

How to read data from a constantly updating xml server? 1 Answer

storing GameObjects/obj on the Internet 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges