public static void InitializeFromDefault() { if (_instance) { DestroyImmediate(_instance); } _instance = Instantiate((AnimalInventory)Resources.Load("AnimalInventoryTemplate")); _instance.hideFlags = HideFlags.HideAndDontSave; }
public static void LoadFromJSON(string path) { if (_instance) { DestroyImmediate(_instance); } _instance = ScriptableObject.CreateInstance <AnimalInventory>(); JsonUtility.FromJsonOverwrite(System.IO.File.ReadAllText(path), _instance); _instance.hideFlags = HideFlags.HideAndDontSave; }
public static void LoadOrInitializeAnimalInventory() { if (File.Exists(Path.Combine(Application.persistentDataPath, "animalinventory.json"))) { Debug.Log("loading animalinventory.json"); AnimalInventory.LoadFromJSON(Path.Combine(Application.persistentDataPath, "animalinventory.json ")); } else { Debug.Log("couldn't find animalinventory, loading from template."); AnimalInventory.InitializeFromDefault(); } }
public static void LoadFromTemplate() { AnimalInventory.InitializeFromDefault(); }