- Home /
OnWillSaveAssets issue
How can I call a editor script when the unity editor loads a scene? Some kind of OnAwake equivalent.
Or right before saving is good al well, I found this: This does not apear to work, the log is not printing when I save the scene:
class SaveManagerEditor extends Editor
{
function OnWillSaveAssets ()
{
Debug.Log("SAVING");
CheckDuplicates();
}
}
Answer by HarshadK · Nov 25, 2014 at 01:22 PM
The OnWillSaveAssets function needs to be static.
Also it has a return type of String array and takes an array of string.
Furthermore the class need to be derived from Asset$$anonymous$$odificationProcessor and not Editor
@Bluestrike: It would help if you would be a bit more precise on what you want to do.
I want to call a function when a scene loads in the editor. So I can check for duplicate id's and then save the scene again.
I tought I found a workaround using a normal script and make it run in edit mode, but EditorUtility.SetDirty does not apear to work in that case.