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
1
Question by TomColdtree · Nov 08, 2017 at 04:37 AM · serializationlevelsdata storage

What is the best way to store and load data for a game with a large number (500) of small levels?

Making my first game. I have finally managed to get both JSON and binary de/serialization working to save/read the data needed to generate a level. Level data is mainly arrays of ints and bools with two structs. (An average level is 1.500 kB in binary and 10kB in JSON)
My game will hopefully have upwards of 500 small puzzle levels. Let's say 100 levels in each 5 catergory of very easy through very hard. What is the best way to store all this data? Do i make a file for each level and load the required level from file. Should i divide the files into directories for each category? Should I put all the level data into an array of levels and save that big array to file? Or something else completely. What is considered best practise or good/bad practice?

Note the data is only level initialising data. I don't need to save any progress level data other then level completed/incomplete which I can do in player prefs.

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
0

Answer by imrankhanswati · Nov 08, 2017 at 08:23 AM

Hi @whocaresitsmeokay :

As far as i know i would like to use one file and all levels in it because if you made too may "json" files unity will create too many "mata" file for them and also for you it will be difficult to manage (from management i mean searching file, updating file, finding errors etc ). But if their is just one file it will be easy to do update and finding errors. and also loading data form exterior file is little slow so if you have many files each for single level then you have to load data for each level form exterior file which will make your game slow. so if you have one file then you just have to load it one time may be at game start or some where else and use it. Also in future if want another level to add in game then you just have to update your levels file and you done.

Their another option called "Scriptable Objects" you can use them if want. Seem pretty good for your situation. https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/scriptable-objects

Might this help... good luck. :)

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 TomColdtree · Nov 09, 2017 at 01:00 AM 0
Share

Thanks for your advice Imran. Loading data for the level from a file on the fly needed doesn't seem to cause a noticable delay . As a check I made the scene reload the level from a file 1000 times and the delay was 1/2 a second. Yes I think one file to hold all levels will be easier then many small files. I can serialise an array of levels or a jagged array of levels sorted in categories. I just worry if deserialising >500 levels at once will cause a delay at startup. Plus I'm holding in memory all the data for every level which seems wasteful. I wastched the Scriptable Objects training video and though they seem powerful I don't think I would need them. They seem to be more for situations where a) many game objects reference the same data and b) where the programmer doesn't want to deal with file management and serialisation and wants to stick to reading data in using the familiar tool of references in the inspector. I have one game object using the level data. Since I have the file read and serialization already working I'll stick to that as is stated in the video link (51:30). This also means I can keep the level generation outside of Unity where I think it might be faster or easier. (Haven't got to that part yet).

I am going to leave the question open to get others opinions. $$anonymous$$aybe someone knows a simple way to have one file yet only deserialise the level needed.

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

76 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

Related Questions

What are the pros and cons of ScriptableObjects vs. JSON for data files? 2 Answers

Binary Serialization (In Editor) - Path Access denied / File not found 0 Answers

android serialization weird path issue " IsolatedStorageException ", javascript 0 Answers

Best practice to store and load a specific set of objects? 3 Answers

Saving Non-Prefab Data During Editor Play 0 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