using System; using System.Collections.Generic; using UnityEngine; namespace SUISSEngine { public abstract class SettingsObject : ScriptableObject where T : SettingsObject { public static T Instance { get { string name = typeof(T).Name; SettingsObject._instance = (Resources.Load(name) as T); if (SettingsObject._instance == null) { SettingsObject._instance = ScriptableObject.CreateInstance(); SettingsObject._instance.platformDependent = new PlatformDependentSettings(SettingsObject._instance.GetKeys()); } return SettingsObject._instance; } } public abstract List GetKeys(); public string GetSetting(string key, string defaultValue = "") { string setting = this.platformDependent.GetSetting(key); if (string.IsNullOrEmpty(setting)) { UnityEngine.Debug.LogWarning(string.Format("{0}: Returning default value ('{1}') for setting '{2}'.", base.GetType(), defaultValue, key)); return defaultValue; } return setting; } private const string SettingsFolder = "Settings/Resources"; private const string AssetExtension = ".asset"; private static T _instance; public PlatformDependentSettings platformDependent; } }