static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions opt)
        {
            if (AssetDatabase.GetMainAssetTypeAtPath(path) == typeof(FontAsset))
                TextResourceManager.RebuildFontAssetCache();

            return AssetDeleteResult.DidNotDelete;
        }
        /// <summary>
        /// Before a DataSetAsset is deleted, unload its Entities to clean up any scene proxies.
        /// </summary>
        /// <param name="assetPath"></param>
        /// <param name="rao"></param>
        /// <returns></returns>
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions rao)
        {
            const AssetDeleteResult Result = AssetDeleteResult.DidNotDelete;

            var dataSet = AssetDatabase.LoadAssetAtPath <DataSetAsset>(assetPath);

            if (dataSet == null)
            {
                return(Result);
            }

            // TODO: Refactor and fix this monstrosity

            var wasDataListWindowOpen = DataListWindow.IsOpen;
            var window = DataListWindow.GetInstance();
            var guid   = AssetDatabase.AssetPathToGUID(assetPath);

            if (!window.IsDataSetOpen(guid))
            {
                return(Result);
            }

            window.RemoveDataSet(guid);

            if (!wasDataListWindowOpen)
            {
                window.Close();
            }

            return(Result);
        }
            public static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions options)
            {
                var asset = AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object));

                if (AssetHasReferences(path, asset))
                {
                    if (EditorUtility.DisplayDialog("Warning. The Asset has references.", $"Stopped the deletion of file {path}\nUse the Track Usage option to find different references" +
                                                    $" which needs to be deleted.\nRemember to Unpack prefab instances aswell by rightclicking the prefab instance and clicking Unpack prefab (completely).",
                                                    "Clean up and Delete", "Close"))
                    {
                        RemoveReferences(path, asset);

                        if (asset is GameObject)
                        {
                            BeforePrefabAssetDestroyed(asset as GameObject);
                        }

                        return(AssetDeleteResult.DidNotDelete);
                    }

                    return(AssetDeleteResult.FailedDelete);
                }
                else
                {
                    if (asset is GameObject)
                    {
                        BeforePrefabAssetDestroyed(asset as GameObject);
                    }

                    return(AssetDeleteResult.DidNotDelete);
                }
            }
Example #4
0
    /// <summary>
    ///     删除文件时候会调用
    /// </summary>
    /// <param name="assetName"></param>
    public static AssetDeleteResult OnWillDeleteAsset(string assetName, RemoveAssetOptions options)
    {
//        Debug.Log("----- delete file, name is " + assetName);
        //return AssetDeleteResult.DidDelete;//不可删除

        return(AssetDeleteResult.DidNotDelete); //可以删除
    }
Example #5
0
        private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
        {
            AssetDeleteResult assetDeleteResult = AssetDeleteResult.DidNotDelete;

            if (!InternalEditorUtility.HasTeamLicense())
            {
                return(assetDeleteResult);
            }
            foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors)
            {
                MethodInfo method = current.GetMethod("OnWillDeleteAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                if (method != null)
                {
                    AssetModificationProcessorInternal.RequireTeamLicense();
                    object[] array = new object[]
                    {
                        assetPath,
                        options
                    };
                    if (AssetModificationProcessorInternal.CheckArgumentsAndReturnType(array, method, assetDeleteResult.GetType()))
                    {
                        assetDeleteResult |= (AssetDeleteResult)((int)method.Invoke(null, array));
                    }
                }
            }
            if (assetDeleteResult != AssetDeleteResult.DidNotDelete)
            {
                return(assetDeleteResult);
            }
            assetDeleteResult = AssetModificationHook.OnWillDeleteAsset(assetPath, options);
            return(assetDeleteResult);
        }
Example #6
0
 public static string[] OnWillDeleteAssets(string[] paths, RemoveAssetOptions option)
 {
     //foreach(string path in paths){Log.Show("Deleting : " + path);}
     Events.Call("On Asset Deleting");
     Events.Call("On Asset Modifying");
     return(paths);
 }
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions rao)
        {
            if (Path.GetExtension(assetPath.ToLower()) != ".abc")
            {
                return(AssetDeleteResult.DidNotDelete);
            }
            var streamingAssetPath = AlembicImporter.MakeShortAssetPath(assetPath);

            AlembicStream.DisconnectStreamsWithPath(streamingAssetPath);

            try
            {
                var fullStreamingAssetPath = Application.streamingAssetsPath + streamingAssetPath;
                File.SetAttributes(fullStreamingAssetPath, FileAttributes.Normal);
                File.Delete(fullStreamingAssetPath);
                File.SetAttributes(fullStreamingAssetPath + ".meta", FileAttributes.Normal);
                File.Delete(fullStreamingAssetPath + ".meta");
            }
            catch (System.Exception e)
            {
                Debug.LogWarning(e);
            }

            return(AssetDeleteResult.DidNotDelete);
        }
        // Checks if deleted folder contains DOTween Pro and in case removes scripting define symbols
        static AssetDeleteResult OnWillDeleteAsset(string asset, RemoveAssetOptions options)
        {
            // Check if asset is a directory
            string dir = EditorUtils.ADBPathToFullPath(asset);

            if (!Directory.Exists(dir))
            {
                return(AssetDeleteResult.DidNotDelete);
            }
            // Check if directory contains DOTweenPro.dll
            string[] files           = Directory.GetFiles(dir, "DOTween.dll", SearchOption.AllDirectories);
            int      len             = files.Length;
            bool     containsDOTween = false;

            for (int i = 0; i < len; ++i)
            {
                if (!files[i].EndsWith("DOTween.dll"))
                {
                    continue;
                }
                containsDOTween = true;
                break;
            }
            if (!containsDOTween)
            {
                return(AssetDeleteResult.DidNotDelete);
            }
            // DOTween found: remove scripting define symbols
            DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine("DOTWEEN_TK2D");
            DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine("DOTWEEN_TMP");
            EditorUtility.DisplayDialog("DOTween Deleted", "DOTween was deleted and any of its scripting define symbols removed.\nThis might show an error depending on your previous setup. If this happens, please close and reopen Unity or reimport DOTween.", "Ok");
            return(AssetDeleteResult.DidNotDelete);
        }
        // This is called when ever an asset deleted
        // If the deleted asset include sdk files, then remove all symbols defined by VIU
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)
        {
            var fullPath     = Application.dataPath + "/../" + assetPath;
            var isDir        = Directory.Exists(fullPath); // otherwise, removed asset is file
            var reqFileFound = false;

            foreach (var symbolReq in s_symbolReqList)
            {
                foreach (var reqFileName in symbolReq.reqFileNames)
                {
                    if (isDir)
                    {
                        var files = Directory.GetFiles(fullPath, reqFileName, SearchOption.AllDirectories);
                        reqFileFound = files != null && files.Length > 0;
                    }
                    else
                    {
                        reqFileFound = Path.GetFileName(fullPath) == reqFileName;
                    }

                    if (reqFileFound)
                    {
                        if (!s_delayCallRemoveRegistered)
                        {
                            s_delayCallRemoveRegistered  = true;
                            EditorApplication.delayCall += RemoveAllVIUSymbols;
                        }

                        return(AssetDeleteResult.DidNotDelete);
                    }
                }
            }

            return(AssetDeleteResult.DidNotDelete);
        }
Example #10
0
        // Handle asset deletion
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)
        {
            if (!Provider.enabled || EditorUserSettings.WorkOffline)
            {
                return(AssetDeleteResult.DidNotDelete);
            }

            if (!Provider.PathIsVersioned(assetPath))
            {
                return(AssetDeleteResult.DidNotDelete);
            }

            Task task = null;

            try
            {
                task = Provider.Delete(assetPath);
                task.SetCompletionAction(CompletionAction.UpdatePendingWindow);
                task.Wait();
            }
            catch (Exception e)
            {
                Debug.LogWarningFormat("Cannot delete path '{0}' by version control: {1}", assetPath, e.Message);
            }

            if (task != null && task.success)
            {
                // We need to check if the provider deleted the file itself or not.
                return(File.Exists(assetPath) ? AssetDeleteResult.DidNotDelete : AssetDeleteResult.DidDelete);
            }

            return(AssetDeleteResult.FailedDelete);
        }
Example #11
0
        private static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions removeOptions)
        {
            if (path.StartsWith("Assets/Scenes/"))
            {
                return(AssetDeleteResult.DidNotDelete);
            }

            PostProcessDeletedAsset(AssetDatabase.LoadAssetAtPath <Object>(path));

            foreach (Object subAsset in AssetDatabase.LoadAllAssetRepresentationsAtPath(path))
            {
                PostProcessDeletedAsset(subAsset);
            }

            return(AssetDeleteResult.DidNotDelete);

            void PostProcessDeletedAsset(Object asset)
            {
                if (asset is IScriptablePostProcess postProcessable)
                {
                    ScriptableAssetPostProcessor.HasDeletedPostprocessableAssets = true;
                    postProcessable.OnPostProcess(true);
                }
            }
        }
Example #12
0
            public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
            {
                UdonSharpProgramAsset programAsset = AssetDatabase.LoadAssetAtPath <UdonSharpProgramAsset>(assetPath);

                if (programAsset)
                {
                    Instance.ClearSourceHash(programAsset);
                }
                else if (AssetDatabase.IsValidFolder(assetPath))
                {
                    string[] assetGuids = AssetDatabase.FindAssets($"t:{nameof(UdonSharpProgramAsset)}", new string[] { assetPath });

                    foreach (string guid in assetGuids)
                    {
                        programAsset = AssetDatabase.LoadAssetAtPath <UdonSharpProgramAsset>(AssetDatabase.GUIDToAssetPath(guid));

                        if (programAsset)
                        {
                            Instance.ClearSourceHash(programAsset);
                        }
                    }
                }

                return(AssetDeleteResult.DidNotDelete);
            }
    // 监听“资源即将被删除”事件
    public static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions option)
    {
        Debug.LogFormat("delete : {0}", path);

        // DidDelete: 可以被删除
        return(AssetDeleteResult.DidDelete);
    }
 static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions _)
 {
     if (assetPath.EndsWith("asset"))
     {
         var assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
         if (typeof(LocalizationTableCollection).IsAssignableFrom(assetType))
         {
             var tableCollection = AssetDatabase.LoadAssetAtPath <LocalizationTableCollection>(assetPath);
             tableCollection.RemoveCollectionFromProject();
         }
         else if (typeof(SharedTableData).IsAssignableFrom(assetType))
         {
             var sharedData = AssetDatabase.LoadAssetAtPath <SharedTableData>(assetPath);
             var collection = LocalizationEditorSettings.GetCollectionForSharedTableData(sharedData);
             collection?.RemoveCollectionFromProject();
         }
         else if (typeof(LocalizationTable).IsAssignableFrom(assetType))
         {
             var table      = AssetDatabase.LoadAssetAtPath <LocalizationTable>(assetPath);
             var collection = LocalizationEditorSettings.GetCollectionFromTable(table);
             collection?.RemoveTable(table);
         }
         else if (typeof(Locale).IsAssignableFrom(assetType))
         {
             var locale = AssetDatabase.LoadAssetAtPath <Locale>(assetPath);
             LocalizationEditorSettings.RemoveLocale(locale, false);
         }
     }
     return(AssetDeleteResult.DidNotDelete);
 }
        private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
        {
            AssetDeleteResult didNotDelete = AssetDeleteResult.DidNotDelete;

            if (!InternalEditorUtility.HasTeamLicense())
            {
                return(didNotDelete);
            }
            foreach (System.Type type in AssetModificationProcessors)
            {
                MethodInfo method = type.GetMethod("OnWillDeleteAsset", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
                if (method != null)
                {
                    RequireTeamLicense();
                    object[] args = new object[] { assetPath, options };
                    if (CheckArgumentsAndReturnType(args, method, didNotDelete.GetType()))
                    {
                        didNotDelete |= (AssetDeleteResult)method.Invoke(null, args);
                    }
                }
            }
            if (didNotDelete != AssetDeleteResult.DidNotDelete)
            {
                return(didNotDelete);
            }
            return(AssetModificationHook.OnWillDeleteAsset(assetPath, options));
        }
Example #16
0
        public static AssetDeleteResult OnWillDeleteAsset(string targetAssetPath, RemoveAssetOptions removeAssetOptions)
        {
            Object mainAssetAtPath = AssetDatabase.LoadMainAssetAtPath(targetAssetPath);

            if (mainAssetAtPath == null)
            {
                return(AssetDeleteResult.DidNotDelete);
            }

            Type type = mainAssetAtPath.GetType();

            if (type.IsSubclassOf(typeof(CollectableScriptableObject)))
            {
                CollectableScriptableObject collectable =
                    AssetDatabase.LoadAssetAtPath <CollectableScriptableObject>(targetAssetPath);

                collectable.Collection.Remove(collectable);
                return(AssetDeleteResult.DidNotDelete);
            }

            if (type.IsSubclassOf(typeof(ScriptableObjectCollection)))
            {
                ScriptableObjectCollection collection =
                    AssetDatabase.LoadAssetAtPath <ScriptableObjectCollection>(targetAssetPath);

                CollectionsRegistry.Instance.DeleteCollection(collection);
                return(AssetDeleteResult.DidNotDelete);
            }

            return(AssetDeleteResult.DidNotDelete);
        }
        static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
        {
            AssetDeleteResult finalResult = AssetDeleteResult.DidNotDelete;

            foreach (var assetModificationProcessorClass in AssetModificationProcessors)
            {
                MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillDeleteAsset", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = { assetPath, options };
                    if (!CheckArgumentsAndReturnType(args, method, finalResult.GetType()))
                    {
                        continue;
                    }

                    finalResult |= (AssetDeleteResult)method.Invoke(null, args);
                }
            }

            if (finalResult != AssetDeleteResult.DidNotDelete)
            {
                return(finalResult);
            }

            finalResult = AssetModificationHook.OnWillDeleteAsset(assetPath, options);

            return(finalResult);
        }
 //--监听“资源即将被删除”事件
 public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)
 {
     if (assetPath.Contains(".cs"))
     {
         UpdateAllScript();
     }
     return(AssetDeleteResult.DidNotDelete);
 }
Example #19
0
 static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)
 {
     if (assetPath.EndsWith(".unity"))
     {
         onWillDelete?.Invoke(assetPath);
     }
     return(AssetDeleteResult.DidNotDelete);
 }
Example #20
0
    private static void OnDeleteAssetCallBack(AssetDeleteResult t, string t1, RemoveAssetOptions t2)
    {
        List <string> paths = new List <string>();

        paths.Add(t1);
        UpdateAsset(paths);
        GlobalEvent.DispatchEvent(EditorGlobalEventEnum.OnDeleteAsset, t, t1, t2);
    }
Example #21
0
 static AssetDeleteResult OnWillDeleteAsset(string assetName, RemoveAssetOptions options)
 {
     AddrHelper.ReloadOnPostProcess = true;
     File.Delete(assetName);
     File.Delete(assetName + ".meta");
     AssetDatabase.Refresh();
     return(AssetDeleteResult.DidDelete);
 }
    private static void OnDeleteAssetCallBack(AssetDeleteResult t, string t1, RemoveAssetOptions t2)
    {
        List <string> paths = new List <string>();

        paths.Add(t1);
        UpdateAsset(paths);
        //Debug.Log("OnDeleteAssetCallBack");
    }
 static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
 {
     if (AssetWatcher.AssetAtPathIsGraphAsset(assetPath))
     {
         Version++;
     }
     return(AssetDeleteResult.DidNotDelete);
 }
    static AssetDeleteResult OnWillDeleteAsset(string name, RemoveAssetOptions options)
    {
        Debug.Log($"Will destroy asset with name {name} and options {options}");

        AssetDeleteResult delRes = AssetDeleteResult.DidNotDelete;

        return(delRes);
    }
Example #25
0
 private static AssetDeleteResult OnWillDeleteAsset(string AssetPath, RemoveAssetOptions rao)
 {
     if (logEnable)
     {
         Log.L(string.Format("Will Delete File \n{0} Options \n{1}", AssetPath, rao));
     }
     return(AssetDeleteResult.DidNotDelete);
 }
Example #26
0
 private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)
 {
     if (assetPath == EditorPrefsTable.HTFrameworkRootPath)
     {
         Log.Error("Delete the HTFramework root folder is not allowed!");
         return(AssetDeleteResult.FailedDelete);
     }
     return(AssetDeleteResult.DidNotDelete);
 }
Example #27
0
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions rao)
        {
            if ("Assets/Photon/PhotonUnityNetworking".Equals(assetPath))
            {
                PhotonEditorUtils.CleanUpPunDefineSymbols();
            }

            return(AssetDeleteResult.DidNotDelete);
        }
 public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)
 {
     if (IsLocked(assetPath))
     {
         Debug.LogError(string.Format("Could not delete {0} because it is locked!", assetPath));
         return(AssetDeleteResult.FailedDelete);
     }
     return(AssetDeleteResult.DidNotDelete);
 }
 public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)
 {
   if (!Provider.enabled)
     return AssetDeleteResult.DidNotDelete;
   Task task = Provider.Delete(assetPath);
   task.SetCompletionAction(CompletionAction.UpdatePendingWindow);
   task.Wait();
   return task.success ? AssetDeleteResult.DidNotDelete : AssetDeleteResult.FailedDelete;
 }
Example #30
0
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions rao)
        {
            if (assetPath.Contains("AQUAS"))
            {
                symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
            }

            return(AssetDeleteResult.DidNotDelete);
        }
Example #31
0
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions rao)
        {
            if ("Assets/MercuryMessaging".Equals(assetPath))
            {
                MercuryThirdPartyUtils.CleanUpMercuryDefineSymbols();
            }

            return(AssetDeleteResult.DidNotDelete);
        }
 private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
 {
     AssetDeleteResult didNotDelete = AssetDeleteResult.DidNotDelete;
     if (!InternalEditorUtility.HasTeamLicense())
     {
         return didNotDelete;
     }
     foreach (Type type in AssetModificationProcessors)
     {
         MethodInfo method = type.GetMethod("OnWillDeleteAsset", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
         if (method != null)
         {
             RequireTeamLicense();
             object[] args = new object[] { assetPath, options };
             if (CheckArgumentsAndReturnType(args, method, didNotDelete.GetType()))
             {
                 didNotDelete |= (AssetDeleteResult) method.Invoke(null, args);
             }
         }
     }
     if (didNotDelete != AssetDeleteResult.DidNotDelete)
     {
         return didNotDelete;
     }
     return AssetModificationHook.OnWillDeleteAsset(assetPath, options);
 }
		private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
		{
			AssetDeleteResult assetDeleteResult = AssetDeleteResult.DidNotDelete;
			if (!InternalEditorUtility.HasPro())
			{
				return assetDeleteResult;
			}
			foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors)
			{
				MethodInfo method = current.GetMethod("OnWillDeleteAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (method != null)
				{
					AssetModificationProcessorInternal.RequireTeamLicense();
					object[] array = new object[]
					{
						assetPath,
						options
					};
					if (AssetModificationProcessorInternal.CheckArgumentsAndReturnType(array, method, assetDeleteResult.GetType()))
					{
						assetDeleteResult |= (AssetDeleteResult)((int)method.Invoke(null, array));
					}
				}
			}
			if (assetDeleteResult != AssetDeleteResult.DidNotDelete)
			{
				return assetDeleteResult;
			}
			assetDeleteResult = AssetModificationHook.OnWillDeleteAsset(assetPath, options);
			return assetDeleteResult;
		}
	static AssetDeleteResult OnWillDeleteAsset( string assetPath, RemoveAssetOptions option )
	{
		//Debug.Log ( "Will delete asset" );
		return AssetDeleteResult.DidNotDelete;
	}
 public static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions options)
 {
     // NOTE: this method is only called when the user has a TeamLicense
     ClearCache();
     return AssetDeleteResult.DidNotDelete;
 }
 private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
 {
   AssetDeleteResult assetDeleteResult = AssetDeleteResult.DidNotDelete;
   if (!InternalEditorUtility.HasTeamLicense())
     return assetDeleteResult;
   foreach (System.Type modificationProcessor in AssetModificationProcessorInternal.AssetModificationProcessors)
   {
     MethodInfo method = modificationProcessor.GetMethod("OnWillDeleteAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
     if (method != null)
     {
       AssetModificationProcessorInternal.RequireTeamLicense();
       object[] objArray = new object[2]
       {
         (object) assetPath,
         (object) options
       };
       if (AssetModificationProcessorInternal.CheckArgumentsAndReturnType(objArray, method, assetDeleteResult.GetType()))
         assetDeleteResult |= (AssetDeleteResult) method.Invoke((object) null, objArray);
     }
   }
   if (assetDeleteResult != AssetDeleteResult.DidNotDelete)
     return assetDeleteResult;
   return AssetModificationHook.OnWillDeleteAsset(assetPath, options);
 }
 public static AssetDeleteResult OnWillDeleteAsset(string str, RemoveAssetOptions opts)
 {
     if (opts == RemoveAssetOptions.MoveAssetToTrash)
     {
         Directory.CreateDirectory("History/" + Path.GetDirectoryName(str));
         var destFileName = "History/" + str;
         if (Directory.Exists(str))
             MoveDirectory(str, destFileName);
         else
             File.Copy(str, destFileName);
         if (File.Exists(str + ".meta"))
             File.Copy(str + ".meta", destFileName + ".meta");
     }
     return AssetDeleteResult.DidNotDelete;
 }