- Home /
Question by
Dracolyte · Dec 12, 2020 at 07:47 AM ·
variablesscene-loadingscene-switchingsave data
Variables are resetting after loading the play scene
In my Main menu scene are upgrade buttons for health etc. These change the variables in another script and it works. My problem is, that these variables are resetting if the scene loads, where you play the game. Is there any method to save these variables without them resetting after each scene load?
//Player's Stat's
[System.NonSerialized] public float
//Things I want so save
playerHp = 100,
MaxPlayerHp = 100f,
playerDmg = 1f,
critDmgMultiplier = 0.5f,
critChance = 20f,
money = 0f,
highscore = 0,
MinPlayerHp = 0f,
HpDecreasePerSec = 15f,
HpBackOnHit = 0f,
HpBackOnKill = 20f,
score = 0;
}
Comment
Best Answer
Answer by gipsnichmeer · Dec 12, 2020 at 08:29 AM
Use Playerprefs. If this is a big project, i would create a VariableManagerScript wich loads all Variables as static and saves all changes in the variables in Playerprefs