private static void CreateAndLoad()
        {
            string filePath = FilePathAttribute.GetFilePath(typeof(T)); //ScriptableSingleton<T>.GetFilePath();

            if (!string.IsNullOrEmpty(filePath))
            {
                InternalEditorUtility.LoadSerializedFileAndForget(filePath);
            }

            if (ScriptableSingleton <T> .s_Instance == null)
            {
                T t = ScriptableObject.CreateInstance <T>();
                t.hideFlags = HideFlags.DontSave;
            }
        }
        public static string GetFilePath(Type sourceType)
        {
            Type typeFromHandle = sourceType;

            object[] customAttributes = typeFromHandle.GetCustomAttributes(true);
            object[] array            = customAttributes;
            for (int i = 0; i < array.Length; i++)
            {
                object obj = array[i];
                if (obj is FilePathAttribute)
                {
                    FilePathAttribute filePathAttribute = obj as FilePathAttribute;
                    return(filePathAttribute.filepath);
                }
            }

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

            string filePath = FilePathAttribute.GetFilePath(typeof(T));

            if (!string.IsNullOrEmpty(filePath))
            {
                string directoryName = Path.GetDirectoryName(filePath);
                if (!Directory.Exists(directoryName))
                {
                    Directory.CreateDirectory(directoryName);
                }

                InternalEditorUtility.SaveToSerializedFileAndForget(new T[] { ScriptableSingleton <T> .s_Instance },
                                                                    filePath, saveAsText);
            }
        }