public static void SetAssetDirty(UnityObject target)
        {
            string      path  = FileManager.GetPath(target);
            UnityObject asset = AssetDatabase.LoadMainAssetAtPath(path);

            Utility.SetDirty(asset, false, true);
        }
 public static string GetGUID(UnityObject target)
 {
                 #if UNITY_EDITOR
     return(AssetDatabase.AssetPathToGUID(FileManager.GetPath(target)));
                 #else
     return("");
                 #endif
 }
Exemple #3
0
 public static bool IsPrefab(this GameObject current)
 {
     if (current.IsNull())
     {
         return(false);
     }
     if (current.hideFlags == HideFlags.NotEditable || current.hideFlags == HideFlags.HideAndDontSave)
     {
         return(true);
     }
                 #if UNITY_EDITOR
     string assetPath = FileManager.GetPath(current.transform.root.gameObject);
     if (!assetPath.IsEmpty())
     {
         return(true);
     }
                 #endif
     return(false);
 }
 public static void SaveFonts(this GUISkin current, string path, bool includeBuiltin = true)
 {
     foreach (var style in current.GetStyles())
     {
         if (!style.font.IsNull())
         {
             string assetPath = FileManager.GetPath(style.font);
             string savePath  = path + "/" + assetPath.GetPathTerm();
             if (!includeBuiltin && assetPath.Contains("unity editor resources"))
             {
                 continue;
             }
             if (!FileManager.Exists(savePath))
             {
                 AssetDatabase.CopyAsset(assetPath, savePath);
             }
         }
     }
 }
 public static T GetAsset <T>(UnityObject target)
 {
                 #if UNITY_EDITOR
     if (Application.isEditor)
     {
         if (!FileManager.assets.ContainsKey(target))
         {
             string assetPath = FileManager.GetPath(target);
             object asset     = AssetDatabase.LoadAssetAtPath(assetPath, typeof(T));
             if (asset == null)
             {
                 return(default(T));
             }
             FileManager.assets[target] = Convert.ChangeType(asset, typeof(T));
         }
         return((T)FileManager.assets[target]);
     }
                 #endif
     return(default(T));
 }
 public static void SaveBackgrounds(this GUISkin current, string path, bool includeBuiltin = true)
 {
     foreach (var style in current.GetStyles())
     {
         foreach (var state in style.GetStates())
         {
             if (!state.background.IsNull())
             {
                 string assetPath = FileManager.GetPath(state.background);
                 string savePath  = path + "/" + state.background.name + ".png";
                 if (!includeBuiltin && assetPath.Contains("unity editor resources"))
                 {
                     continue;
                 }
                 if (!FileManager.Exists(savePath))
                 {
                     state.background.SaveAs(savePath, true);
                 }
             }
         }
     }
 }
        public static FileData Get(UnityObject target, bool showWarnings = false)
        {
            string path = FileManager.GetPath(target, false);

            return(FileManager.Find(path, showWarnings));
        }
Exemple #8
0
        public static FileData Get(UnityObject target, bool showWarnings = false)
        {
            string path = FileManager.dataPath.Replace("Assets", "") + FileManager.GetPath(target);

            return(FileManager.Find(path, showWarnings));
        }
 //============================
 // AssetsDatabase
 //============================
 public static bool IsAsset(UnityObject target)
 {
     return(!FileManager.GetPath(target).IsEmpty());
 }
 public static string GetAssetPath(this UnityObject current)
 {
     return(FileManager.GetPath(current));
 }