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 Caiuse · Jun 07, 2012 at 08:16 AM · xmlsavingbytearray

Local data saves on iOS (best practices)

I've been working on an iOS project based around using the GameCenter for turn based matches. As it stands everytime a player leaves the match the matches current state (in our case object positions) are parsed to a byte array then serialized as XML.

Really saving to XML is probably completely unnecessary as the same class which saves this data also opens and parses it. What would be the best format to save the data for extremely fast retrieval and saving. A few ideas I had were to save the byte array to a raw text document.

Any ideas? C.

Comment
Add comment · Show 3
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 arkon · Jun 07, 2012 at 08:39 AM 0
Share

You could save your byte array to player prefs. $$anonymous$$ight be easier. Not sure about speed, although I can't imagine it being slower than parsing an X$$anonymous$$L file.

avatar image Caiuse · Jun 07, 2012 at 08:50 AM 0
Share

I like that idea, would I have to serialise the by$$anonymous$$rray to a String, or does PlayerPrefs support raw by$$anonymous$$rrays... guess I'll find out myself haha!

avatar image Fattie · Jun 07, 2012 at 09:23 AM 0
Share

it's hard to believe there could possibly be any performance issue imaginable here dude ?!?!!! have you actually tried it? How big is the X$$anonymous$$L file, are you talking gigabytes or something??????

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by whydoidoit · Jun 07, 2012 at 11:54 AM

I agree with @Fattie in the comments, but if you want to convert a byte array into a string without the XML (not sure what that would be doing that was too slow) you can use

    var myString = Convert.ToBase64String(yourByteArray);

And to revert

     var myByteArray = Convert.FromBase64String(myString);
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 sims11tz · Oct 05, 2012 at 12:06 AM 0
Share

What is your code to create the Byte Array? I am working on a game for ios and I am trying to use BinaryFormatter which is not working. Do you know of an alternative to create a byte array from a object?

avatar image whydoidoit · Oct 05, 2012 at 06:11 AM 1
Share

Well you can use this. You could directly use

   var data = UnitySerializer.Serialize(yourObject);

and

    UnitySerializer.Deserialize<SomeClass>(data)
avatar image Caiuse · Oct 05, 2012 at 09:01 AM 0
Share

UnitySerializer had no idea that class existed! That's going to save some hours in the future :D Thanks @whydoidoit

avatar image whydoidoit · Oct 05, 2012 at 09:02 AM 0
Share

You do need to install Unity Serializer from that link I provided...

avatar image AlexHogan · Oct 29, 2012 at 05:04 AM 0
Share

@whydoidoit I'm jumping in with UnitySerializer tonight - can't wait ot share my experiences.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Saving usermade creations in game 1 Answer

Saving serializable class list at runtime. 1 Answer

XML, Saving Data of Lists gives error 1 Answer

Saving data to xml file (I have the loading down) 0 Answers

Need experienced opinion: Saving a players inventory: XML or PlayerPrefs? 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