- Home /
How to make Save Game feature?
I was wondering how can I make a simple save game feature using the Unity GUI? Just a simple save game feature that will save your progress and inventory, stuff like that. Any help would be appreciated! Thanks!
Answer by whydoidoit · Jul 05, 2012 at 06:18 PM
It's far from simple to do a save game feature. I have this free package that can help.
If you want to do it yourself you would serialize the information to PlayerPrefs - you can store custom classes using BinaryFormatter or an Xml Serializer and Convert.ToBase64String() or you can just write values directly.
I don't recommend using the built in System.Runtime.Serialization stuff, Unity tends to break it's functionality and can do some really weird stuff with it sometimes (like, if you have a reference to a [Serializable] object from a static object in your code, Unity will instantiate that object against your wishes during the static initialization phase)
Yeah good point it does use that internally - actually you can serialize a POCO class (Plain Old CLR Object) without specific Serializable decoration using BinaryFormatter.
What does your free package do? Does it work to where I can have it save game?
Yes that is what it does - there is a video and an explanation in the link I posted in my answer.
O$$anonymous$$...I downloaded...but yet...I get a "All compiler errors must be fixed" error in Unity. How can I set this program up?
Answer by Jake Haas · Jul 05, 2012 at 08:40 PM
If you don't want to buy any plugins, player prefs are probably the best way to go.
http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html
I would like it to save in-game. So they say Player prefs would not be the best choice in game.
I should point out you don't need to buy my plug in :)
I would use your plugin if i could figure out whats wrong with error messages.
See comment above - it must conflict with one of your existing classes - but I can't help you with that if I don;t know what the messages are.
The only error I get is that all compiler errors must be fixed before entering play mode.
Answer by kurotatsu · Jul 06, 2012 at 03:58 AM
I use PlayerPrefs, and asked a similar question earlier here.
It has a working example of saving a players position. It should help you get an Idea of how to actually impliment the saving and loading by calling the functions in the script.
Hope it helps.(if it works for ya maybe give a brother an upvote, and click the answer checkmark.:))
Answer by RaysFan · Jul 06, 2012 at 01:49 PM
Thanks anyways...I will continue to look around. Thanks for trying to help me out.
Answer by RaysFan · Jul 11, 2012 at 08:50 PM
I am trying to figure out script for playerprefs......am very confused. Any help would be appreciated.
I updated the script in my link to be a drag and drop solution for ya, it should work now.
Don't forget ta vote and check the answer checkmark, so questions don't show up in searches as unanswered.:)
Your answer
Follow this Question
Related Questions
How to store a boolean for each variable in a class 1 Answer
Unity 3D 2018.1 - Save 0 Answers
load button in main menu 1 Answer
Level creator save bug. 0 Answers
Saving Instantiates in safe file? 1 Answer