using UnityEngine; namespace ShrinkTutorial { public sealed class PlayerPrefsShrinkTutorialStorage : IShrinkTutorialStorage { private readonly string _storageKey; public PlayerPrefsShrinkTutorialStorage(string storageKey) { _storageKey = string.IsNullOrWhiteSpace(storageKey) ? "ShrinkTutorial.Progress" : storageKey; } public ShrinkTutorialProgress Load() { if (!PlayerPrefs.HasKey(_storageKey)) return new ShrinkTutorialProgress(); var json = PlayerPrefs.GetString(_storageKey, string.Empty); if (string.IsNullOrWhiteSpace(json)) return new ShrinkTutorialProgress(); return JsonUtility.FromJson(json) ?? new ShrinkTutorialProgress(); } public void Save(ShrinkTutorialProgress progress) { var json = JsonUtility.ToJson(progress ?? new ShrinkTutorialProgress()); PlayerPrefs.SetString(_storageKey, json); PlayerPrefs.Save(); } public void Reset() { PlayerPrefs.DeleteKey(_storageKey); PlayerPrefs.Save(); } } }