コード例 #1
0
 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();
     Debug.Log(filePath);
     if (!string.IsNullOrEmpty(filePath))
     {
         //var asset = AssetDatabase.LoadAssetAtPath<ScriptableObject>(filePath);
         //if (asset)
         //{
         //    ScriptableSingleton<T>.s_Instance = asset as T;
         //}
         //else
         //{
         //    ScriptableSingleton<T>.s_Instance = ScriptableObject.CreateInstance<T>();
         //}
         // // InternalEditorUtility.LoadSerializedFileAndForget(filePath);
     }
     if (!((Object) ScriptableSingleton<T>.s_Instance == (Object) null))
     {
         Debug.Log("not null!");
         return;
     }
     
 }