I am making a game with a few stages, and those stages have ten levels each, in C#, how would you make a script, that when level ten of stage one is completed, tell another script in another scene that level ten of stage one is finished and unlock stage two.
-
Id say to use playerprefs to save them kind of values – JRowan Jun 02 '17 at 02:16
-
11Possible duplicate of [Unity - pass data between scenes](https://stackoverflow.com/questions/32306704/unity-pass-data-between-scenes) – Serlite Jun 02 '17 at 02:20
-
1It's answered here https://stackoverflow.com/questions/44320987/unity-c-how-do-i-call-a-listint-from-a-different-scene – rohankad Jun 02 '17 at 05:43
2 Answers
You can either save them in a PlayerPrefs:
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
Or in files:
https://unity3d.com/learn/tutorials/topics/scripting/persistence-saving-and-loading-data
Or simply store your variables in a Monobehaviour script on a game object that is persistent between scenes like GameManager (it has to be using DontDestroyOnLoad() function in Awake())

- 1,196
- 2
- 13
- 23
-
Thank you very much for the help, except how would I use playerprefs? – smartbot Jun 03 '17 at 15:15
-
Every time you need to save something just use PlayerPrefs. For example: PlayerPrefs.SetFloat("Player Health", playerHealthVariable); and then when you change your scene you can use PlayerPrefs.GetFloat("Player Health"); – Fiffe Jun 03 '17 at 20:36
-
Actually there are several different ways to do this job. We can categorize it into two types
- Local
- Server Based
Local means on your system like player prefas or don't destroy on load while server based include database where you keep track of specified user and update its data regularly to allow or unlock different levels. Database will be slightly hard for you as you have to write server side code, require database creation and internet for end user. So it easy for you to user local options like You can also read my detail answer here Best way to save data in unity.

- 10,013
- 18
- 97
- 186