Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Bleackk · Apr 07, 2016 at 06:17 PM · c#saveload

OnApplicationQuit

So. I've read the OnApplicationQuit() thing in the Docs around 50 times now. And i still have no clue how to Save my WHOLE game state. How would i go About saving a virtual pet game, I have Items you can Buy, Incemental systems and a simple day and night cycle. O Also read about Player Prefs but how would i go about it. I Really tried like a Gazillion times and it didn't work. And once i've saved i'd like it to load it automaticly every time i run the game. I don't have any Scripts to this, i heard something about Serialization. I need explainations ._. (Working in Unity 5.4b)

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

2 Replies

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

Answer by Rob2309 · Apr 07, 2016 at 06:27 PM

First of all, to be able to save your gamestate, you should begin by thinking about exactly what variables you have to save... Then you could write some wrapper classes that hold these values. You can then, when exiting the application save all those objects via serialization (basically writing an object as a stream of bytes, read more about this yourself please :D). To load all this you could add a gameobject to your startup scene that reads the created files back in in its start method... Those are only very general tips I can give you, but you have to specialize this basic system for your project yourself, as I don't know what exactly you are trying to save...

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 Bleackk · Apr 07, 2016 at 06:53 PM 0
Share

You sir just made my work so much easier. This helps a LOT. I'll learn up on Serialization then and Save Variables. As I'm making a Virtual Pet/Incremental game the main variables would be Health of the Pet, item and upgrade counts and such. Allright. Thanks, Have some points

avatar image
0

Answer by b1gry4n · Apr 07, 2016 at 10:39 PM

http://docs.unity3d.com/ScriptReference/PlayerPrefs.html

Save examples:

 PlayerPrefs.SetString("petName","Bleackk");
 PlayerPrefs.SetFloat("petHealth",25);
 PlayerPrefs.SetInt("upgradeLevel",3);

Load examples:

 string tempPetName = PlayerPrefs.GetString("petName");
 float tempPetHealth = PlayerPrefs.GetFloat("petHealth");
 int tempUpgrade = PlayerPrefs.GetInt("upgradeLevel");

assign the temp values to whatever you want.

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 Bleackk · Apr 07, 2016 at 11:15 PM 0
Share

This is also very helpfull. I'm greatfull :). Have some Points :3

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

139 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help offline progression, works on windows but not on Android. 0 Answers

Save game - Tile based game 0 Answers

Loading live data to Unity from Processing 0 Answers

I can't figure out why my score doesn't save/increase 0 Answers

Save/Load Player System 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