Почему не сохраняются деньги после смерти в значении_monetT unity 3d
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UIElements;
public class Score : MonoBehaviour
{
public TMP_Text _text;
public static int _score = 0;
public static int _scoreT = 3;
public TMP_Text _textT;
public GameObject _restartGame;
public TMP_Text _money;
public int _moneyT;
private bool _moneyUp = false;
private void Start()
{
_restartGame.SetActive(false);
_moneyT = PlayerPrefs.GetInt("Money", 0);
}
private void Update()
{
_text.text = "$" + _score;
_textT.text = "Осталось жизней: " + _scoreT;
if (_scoreT == 0 && !_moneyUp)
{
_restartGame.SetActive(true);
_moneyT += _score;
PlayerPrefs.SetInt("Coins", _moneyT);
PlayerPrefs.Save();
_moneyUp = true;
}
_money.text = "всего" + _moneyT;
Debug.Log(_moneyT);
}
public void RestartGame()
{
_moneyUp = false;
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
_restartGame.SetActive(false);
_score = 0;
_scoreT = 3;
}
}
Источник: Stack Overflow на русском