Вы можете использовать PlayerPrefs
, чтобы сохранить свои уровни в нескольких сценах. Вы просто присваиваете значение в своей сцене повышения уровня и получаете доступ к значению во время загрузки нового.
PlayerPrefs.GetInt(string key)
получает значение переменной в «ключе».
PlayerPrefs.SetInt(string key, int value)
сохраняет значение в переменной в ключе
Уровень выше
// Access the previous value
int speed = PlayerPrefs.GetInt("Speed");
// Increment the value
speed++;
/// Store the value
PlayerPrefs.SetInt("Speed", speed);
Уровень нагрузки
void Start
{
// Load stats
int speed = PlayerPrefs.GetInt("Speed");
int strength = PlayerPrefs.GetInt("Strength");
int health = PlayerPrefs.GetInt("Health");
int stamina = PlayerPrefs.GetInt("Stamina");
}