using Core; using Script.Gameplay.Input; using UnityEngine; namespace Script.Gameplay.Global { public class GameDataManager : MonoSingleton { private const string LoopCountKey = "TotalLoopCount"; public int TotalLoopCount { get; private set; } private void Start() { GameManager.Instance.OnGameStart += AddLoop; // 读取已保存的循环次数 TotalLoopCount = PlayerPrefs.GetInt(LoopCountKey, 0); Debug.Log("目前循环次数:" + TotalLoopCount); } public void AddLoop() { TotalLoopCount++; PlayerPrefs.SetInt(LoopCountKey, TotalLoopCount); PlayerPrefs.Save(); } } }