- Home /
Has anyone successfullly used SaveAssetsProcessor?
I can't seem to hook into this: SaveAssetsProcessor. The documentation is severely lacking, as in not even listing a return value.
I have the following code as a start, but can't seem to get anything to happen ever...
using UnityEngine;
using UnityEditor;
using System.Collections;
public class FileModificationWarning : SaveAssetsProcessor {
string[] OnWillSaveAssets (string[] paths) {
Debug.Log("OnWillSaveAssets");
foreach(string path in paths)
Debug.Log(path);
return paths;
}
}
I've tried having OnWillSaveAssets be void as well, but no luck and no errors to indicate what could possibly be wrong.
Answer by Byterunner · Mar 29, 2011 at 12:17 AM
Solved it. The function needs to be static:
using UnityEngine;
using UnityEditor;
using System.Collections;
public class FileModificationWarning : SaveAssetsProcessor {
static string[] OnWillSaveAssets (string[] paths) {
Debug.Log("OnWillSaveAssets");
foreach(string path in paths)
Debug.Log(path);
return paths;
}
}
$$anonymous$$ark your answer as an answer! And I believe you get a badge ;). Haha!
Does this actually work? All I can get it to do is run the function but paths is always empty.
Yes, it does, though not always as you'd expect. I created a prefab out of a cube, saved it and added it to a scene, which I saved. Now when I open the scene and modify the prefab, apply the changes and save scene and it prints out the name of the scene and the prefab. If I modify the properties on a texture importer and apply the changes and save project, it will run the function, but not print the path. I'm not sure how to get that to work, but it's out of the scope of what I need so I didn't pursue it.
Hey this is exactly happening with me did you find the fix ?
also when the error came unity get stuck and when I switch to different app the error come once always
Note that this class is obsolete. Ins$$anonymous$$d use Asset$$anonymous$$odificationProcessor: http://docs.unity3d.com/ScriptReference/Asset$$anonymous$$odificationProcessor.html
Your answer
Follow this Question
Related Questions
Editor scripting - How to show the Assets menu as a context menu 1 Answer
Cannot close/unload a scene that is open in editor during playmode (using C# code)? 3 Answers
Stop a MonoBehavior from being addable as a script? 0 Answers
How To Best Match Editor GUI Content Heights 0 Answers
runInBackground in Edit Mode 0 Answers