protected virtual void Save(bool saveAsText)
        {
            if ((Object)ScriptableSingleton <T> .s_Instance == (Object)null)
            {
                Debug.Log((object)"Cannot save ScriptableSingleton: no instance!");
            }
            else
            {
                string filePath = ScriptableSingleton <T> .GetFilePath();

                if (string.IsNullOrEmpty(filePath))
                {
                    return;
                }
                string directoryName = Path.GetDirectoryName(filePath);
                if (!Directory.Exists(directoryName))
                {
                    Directory.CreateDirectory(directoryName);
                }
                InternalEditorUtility.SaveToSerializedFileAndForget((Object[])new T[1]
                {
                    ScriptableSingleton <T> .s_Instance
                }, filePath, (saveAsText ? 1 : 0) != 0);
            }
        }
Пример #2
0
        private static void CreateAndLoad()
        {
            string filePath = ScriptableSingleton <T> .GetFilePath();

            if (!string.IsNullOrEmpty(filePath))
            {
                InternalEditorUtility.LoadSerializedFileAndForget(filePath);
            }
            if (ScriptableSingleton <T> .s_Instance == null)
            {
                ScriptableObject.CreateInstance <T>().hideFlags = HideFlags.HideAndDontSave;
            }
        }
Пример #3
0
        protected virtual void Save(bool saveAsText)
        {
            if (ScriptableSingleton <T> .s_Instance == null)
            {
                Debug.Log("Cannot save ScriptableSingleton: no instance!");
            }
            else
            {
                string filePath = ScriptableSingleton <T> .GetFilePath();

                if (!string.IsNullOrEmpty(filePath))
                {
                    string directoryName = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(directoryName))
                    {
                        Directory.CreateDirectory(directoryName);
                    }
                    T[] localArray1 = new T[] { ScriptableSingleton <T> .s_Instance };
                    InternalEditorUtility.SaveToSerializedFileAndForget(localArray1, filePath, saveAsText);
                }
            }
        }