- Home /
Is there any way to automatically run an editor script when an asset is moved or renamed?
Basically, levels in my game are loaded from XML files. Each element in the XML files have a path to the resource that they load. Right now, if I move or rename an asset without adjusting the paths in the XML files, they will no longer match up and the game will be unable to find the assets. To solve this, I wrote editor scripts that automatically move/rename given assets and refactor all the XML files accordingly.
This works fine, but I would prefer if I could run these scripts automatically by using the existing tools for renaming and moving. Is there any way I can say "Hey unity, if someone moves or renames an asset, also do these things"?
Answer by Glurth · Jul 28, 2017 at 04:39 PM
https://docs.unity3d.com/ScriptReference/EditorApplication-projectWindowChanged.html
e.g.
EditorApplication.projectWindowChanged+= myToolFunction;
While I have never used this myself, from the description, it sounds like what you want.