Answer the question
In order to leave comments, you need to log in
What is the best way to organize the save?
There is a script in which it is necessary to implement saving. What is the best way to do this, in the sense that if everything is stuffed into fixupdate, then the phone will be heavily loaded? Damage and Money change throughout the game, changes almost all the time.
here is the script with the method
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Balance : MonoBehaviour
{
public int Money;
public int Damage;
public Text Money_Text;
public void FixedUpdate()
{
Money_Text.text = "Коины: " + Money.ToString() ;
}
public void Save() // сохранение, которое не знаю в какой момент лучше всего вызывать
{
string key = "Balance" ;
PlayerPrefs.SetInt(key, this.Money);
PlayerPrefs.SetInt(key, this.Damage);
PlayerPrefs.Save();
}
public void Load()
{
string key = "Balance";
if (PlayerPrefs.HasKey(key))
{
PlayerPrefs.SetInt(key, this.Money);
PlayerPrefs.SetInt(key, this.Damage);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question