- Home /
Detecting scene save - replacement for AssetModificationProcessor.OnWillSaveAssets
In Unity 5, how does one detect when the user performs a save in the Editor, in order to run a validation script (like checking that certain necessary GameObjects exist)?
This used to be possible with AssetModificationProcessor.OnWillSaveAssets, but it seems to be obsolete now. The documentation page for AssetModificationProcessor says, confusingly:
Obsolete
Use UnityEditor.AssetModificationProcessor
http://docs.unity3d.com/ScriptReference/AssetModificationProcessor.html
Answer by sient · Aug 15, 2015 at 09:11 PM
iirc, there is a UnityEngine.AssetModificationProcessor
but also a UnityEditor.AssetModificationProcessor
. You're using the UnityEngine
one.
So change the class declaration to
class MyProcessor : UnityEditor.AssetModificationProcessor {
// ...
}
Aha, I never spotted the namespace difference! That did the trick.
Really, the docs should have just said "This class was moved to the UnityEditor namespace"...
Your answer
![](https://koobas.hobune.stream/wayback/20220613192425im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to add Animation Curves on Imported Clips by Script 1 Answer
How to make a editor script that sets the values of serialized variables in the editor 1 Answer
Is there some callback for importing FBX into scene? 0 Answers
Editor Window Views 0 Answers
Editor Script Selection thinks Sprites are Texture2Ds. 2 Answers