i am creating a game in unity, its having a problem that it reset the value of a var whenever i reopen it. so,how to assign a value inside an if statement and store its value forever even if you restart the program in C#?
Asked
Active
Viewed 70 times
-3
-
1By saving it somewhere like a file, database, or the registry. Then you read it back on startup. – ProgrammingLlama Jun 24 '21 at 07:02
-
3Apparently there's a thing called "PlayerPrefs" in Unity: https://docs.unity3d.com/ScriptReference/PlayerPrefs.html – ProgrammingLlama Jun 24 '21 at 07:03
-
oh! let me check – Yash Verma Jun 24 '21 at 07:05
1 Answers
-1
you could store the value in a database and open that database whenever you want to view or change that value. So, it would be unaffected even if you restart your program or application.check this to save to a Microsoft SQL server

Rithik Sunny
- 21
- 2
-
1Not advised with Unity you can simply use ```PlayerPrefs``` to save data over multiple runs no external database needed. – IndieGameDev Jun 24 '21 at 07:18