• 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 O Leddy · Apr 11, 2011 at 03:50 AM · guigamesavesaveload

How to let the player save progress

Basically, I would like to know how to make it so that a player can save their progress and open a saved game again from a menu. I am new to game design so, hopefully, someone can leave me an answer that is not too complicated. I know there are already a few instances of questions similar to this one, so I apologize for creating a sort of unnecessary thread, but I did not fully understand some of the answers to the other questions like this one. I can do a simple GUI menu, but I have no idea how to actually create and load a save file. Please advise. I am sure many others may benefit from your responses. Thank you!

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
1
Best Answer

Answer by _Petroz · Apr 11, 2011 at 05:15 AM

This is known as serialization. There is essentially two parts to this question, how to serialize data, how to do file I/O. When I did serialization for my game I used PlayerPrefs which worked quite well. If you specifically want to write out to file with your own file format specification that is another matter which I don't have any experience with in Unity.

With serialization the first step is to determine what part of the game state is important to save and load, and which state can be easily thrown away.

For example: the player's health, the player's money, the player's position are things you probably want to save. The state of a particle emitter, or the soundsystem are things which you can happily discard.

Once you have determine what to save, now you just have to save them. A common approach is to have every object know how to save itself. So every object which contains state you want to save would have a function called something like 'writeSaveFile' and a matching read, 'readSaveFile'. Inside those functions you perform the serialization, making sure that the save and load function match exactly.

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 zmar0519 · Apr 12, 2011 at 01:40 AM 0
Share

look on the unify community wikki for an xml serialization script, which does what Petroz described above.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Error while saving game: SerializationException: Type 'UnityEngine.GameObject' in Assembly 'UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable. 0 Answers

The name "Game Foundation" does not exist in the current context 1 Answer

Clearing a GUI and Pausing a Game 1 Answer

Drag and Drop menu and Save load game. 0 Answers

Save Question (PLZ HELP) 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