// Detect Asset Deletion /
-
static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
-
{
-
AssetDeleteResult finalResult = AssetDeleteResult.DidNotDelete;
-
if (!InternalEditorUtility.HasTeamLicense())
-
return finalResult;
-
...
-
using UnityEngine;
-
using UnityEditor;
-
public class Test : UnityEditor.AssetModificationProcessor
-
{
-
static void OnWillCreateAsset(string assetName)
-
{
-
Debug.Log("OnWillCreateAsset is being called with the following asset: " + assetName + ".");
-
}
-
static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions opt)
-
{
-
Debug.Log("OnWillDeleteAsset");
-
Debug.Log(path);
-
return AssetDeleteResult.FailedDelete;
-
}
-
}
-
static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions opt)
-
{
-
if (AssetDatabase.GetMainAssetTypeAtPath(path) == typeof(MyType))
-
{
-
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(AssetDatabase.LoadAssetAtPath<MyType>(path), out var guid, out long id))
-
Lucene.DeleteDocument(guid);
-
}
-
return AssetDeleteResult.DidNotDelete;
-
}
///