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 MrSplosion · Oct 17, 2011 at 10:32 PM · readformat

Best Storage Method

I'm making a 2D Minecraft or Terraria style game and I'm not sure on how to handle the storage portion for each block. Temporarily I have three arrays called blockType, posX and posY. If I want to read and write each of these arrays in some file what should the format be?

Thanks.

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 Julien-Lynge · Oct 17, 2011 at 11:47 PM

This seems like a largely philosophical question. How are you going to be accessing the data? Do you just want to write the temporary arrays into the file and then read them back out? Do you want to store indexed entries and get an entry by index? Are you saving when closing the program and reading when opening, or accessing during runtime, and are you going to have multiple threads attempting to read the file at the same time?

Perhaps you should first look at serialization (here and here) to produce binary files. Or, you could write the data out in xml format if you prefer and it's not too large.

If you can give me a little more information on what you're trying to do, I can give you some better ideas on how to go about reading and writing the data.

Comment
Add comment · Show 2 · 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 MrSplosion · Oct 18, 2011 at 09:29 PM 0
Share

Yeah sure! Here we go: I guess I want to write out the arrays in a file (I'm not sure how else they'd get there). Yes I would like to store indexed entries because I think checking to see which values are closest to my player then showing those blocks with the corresponding position values would possibly be a good culling system (I don't have unit pro with the occlusion culling built in feature). $$anonymous$$aybe something like:

blocks, type, position, X, Y,

Or something I'm not sure. I will be saving when closing the program but only like the player position and what he has in his inventory nothing huge. However when the program writes the block data to a file will be when you generate a new world it's not procedural. Yes I'll access it during runtime because I need a culling system so I'll have to show and hide blocks depending on the players position at runtime. I'll just have one thread parsing the data that's really all I need nothing too complex.

About serialization, I definitely want it because I don't want people able to just open the file and edit the block types to all diamonds lol.

Just ask if you or someone else needs more information.

avatar image CarlLawl · Oct 19, 2011 at 10:23 PM 0
Share

You could just use playerprefs? If you want to store arrays in playerprefs there is a script on the unify wiki which is located here

http://www.unifycommunity.com/wiki/index.php?title=ArrayPrefs2

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

PlayerPrefs.GetString returns wrong value 3 Answers

Can Unity use .ini files? 1 Answer

How to write/read .txt on FTP (Javascript) 3 Answers

Reading files in Unity from different platform 2 Answers

Using System.IO for Diary? 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