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 lancer · Aug 07, 2013 at 11:46 PM · playerprefssavingstate saving

Sate Saving

The game I'm making is going to be very complicated, there will be several things that move and hundreds of separate variables, it would take weeks of work to save it all using PlayerPrefs. Is there an easier way to do saving, like saving the state that the scene is in?

Comment
Add comment · Show 2
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 robertbu · Aug 08, 2013 at 12:01 AM 0
Share

Unity Serializer.

avatar image savlon · Mar 29, 2016 at 11:43 PM 0
Share

This may be able to help http://program$$anonymous$$gtutorials.thinkific.com/courses/5-methods-to-saving-and-loading-your-game-data-in-unity3d

If you use the coupon code SAVE$$anonymous$$E you get 50% off.

1 Reply

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

Answer by Slobdell · Aug 08, 2013 at 12:04 AM

I'm going ahead assuming that your using C#. FIrst off there are some libraries that will do this. See here http://forum.unity3d.com/threads/138678-Unity-Save-Game-Level-Serialization. For myself I've never needed the entire scene saved. So what I do is create a class that stores all the data I'm looking to save. Then using the XMLSerializer class for C#, see here http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx, I serialize my class into XML which is just text and save it as a string to one SINGLE playerprefs variable. I can explain further if you need, let me know

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 Slobdell · Aug 08, 2013 at 12:08 AM 0
Share

Actually that X$$anonymous$$LSerializer link I sent you looks like more than you need. This how I serialize my player class. I have one going the other way too makes converting back and forth as simple as calling one method.

 public static String toX$$anonymous$$L(Player player){
         XmlSerializer x = new XmlSerializer(typeof(Player));
         $$anonymous$$emoryStream memoryStream = new $$anonymous$$emoryStream();
         
         XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false));
         x.Serialize(xmlTextWriter, player);
         memoryStream = ($$anonymous$$emoryStream)xmlTextWriter.BaseStream;        
         return System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
     }

Also, something I learned the hard way, this line is key "new XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false));" . The false turns of BO$$anonymous$$, Using different encoding gave me all kinds of errors due to Unity encoding acceptance and byte order marks which I don't even know what that really means but it's bad in this case.

avatar image lancer · Aug 08, 2013 at 12:16 AM 0
Share

It works :) thanks, ill put you in the credits for my game!

you just saved me hours of coding to try to use PlayerPrefs to do this, Thanks so much.

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

16 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

Related Questions

How to create a save and load game proccess like SCP: Containment Breach? 0 Answers

Save Values On Closing of Game 1 Answer

Saving Location in Unity 1 Answer

Questions about changes to UnityEngine.Random. Random.Seed deprecated 3 Answers

How to save players rotation in Unity? PlayerPrefs 3 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