using UnityEditor; using UnityEngine; namespace Stary.Evo.Example.Counter { public interface IStorage:IUtility { void SaveInt(string key, int value); int LoadInt(string key, int defaultValue = 0); } public class PlayerPrefsStorage : IStorage { public void SaveInt(string key, int value) { Debug.Log("PlayerPrefsStorage执行"); PlayerPrefs.SetInt(key, value); } public int LoadInt(string key, int defaultValue = 0) { return PlayerPrefs.GetInt(key, defaultValue); } } public class EditorPrefsStorage : IStorage { public void SaveInt(string key, int value) { #if UNITY_EDITOR Debug.Log("EditorPrefsStorage执行"); EditorPrefs.SetInt(key, value); #endif } public int LoadInt(string key, int defaultValue = 0) { #if UNITY_EDITOR return EditorPrefs.GetInt(key, defaultValue); #else return 0; #endif } } }