- Home /
How to use OnWIllDeleteAsset - Not being called
I'm currenty trying to find a way around using .net FileSystemWatcher as when a file delete callback is sent its too late to get anything from the object. I found out about AssetModificationProcessor and its OnWillDeleteAsset and its just what i need, but i cannot impliment it so far i have this;
[InitializeOnLoad]
public class ObjectDatabaseEditor : UnityEditor.AssetModificationProcessor {
//
public static AssetDeleteResult OnWillDeleteAsset(string AssetPath, RemoveAssetOptions rao)
{
Debug.Log("deleted - unity callback: " + AssetPath);
return AssetDeleteResult.DidNotDelete;
}
//
}
But it does not get called.
Were you able to make it work? I'm having the same problem.
Answer by Eldoir · Jan 29, 2019 at 10:35 AM
Hey, It's a bit late but I also ran into this issue and I think I figured out. Unfortunately, if I read the source file correctly at lines 216-217, the: if (!InternalEditorUtility.HasTeamLicense()) return finalResult; prevents your AssetModificationProcessor from calling OnWillDeleteAsset if you don't have a Team License. I left a feedback on their doc page, they should precise that.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
[ExecuteInEditMode] OnEnable Running twice on Play? 1 Answer
Working with Unity Editor 1 Answer
Double Array (Custom Editor) 1 Answer