I want to save values of some variables. I tried to save it to file, but it doesn't work. So now I try it in another way. But it don't save data too... If I start simulation i Unity, change values of variables, stop simulation and then start it again, I have old values of the variables..
void OnEnable()
{
LoadFromFile();
}
void OnDisable()
{
SaveToFile();
}
public void SaveToFile()
{
GameObject gameManagerObject = GameObject.FindGameObjectWithTag("GAMEMANAGER");
GAMEMANAGER gameManager = gameManagerObject.GetComponent<GAMEMANAGER>();
IndicatorsInfo indicatorsInfo = new IndicatorsInfo();
PlayerPrefs.SetFloat("my_setting", indicatorsInfo.walkSpeedTemfFile);
}
public void LoadFromFile()
{
GameObject gameManagerObject = GameObject.FindGameObjectWithTag("GAMEMANAGER");
GAMEMANAGER gameManager = gameManagerObject.GetComponent<GAMEMANAGER>();
gameManager.walkSpeedTemp = PlayerPrefs.GetFloat("my_setting");
}
[Serializable]
class IndicatorsInfo
{
public float walkSpeedTemfFile;
}