- Home /
How do I register undo for the moving/renaming of a folder along with the assets contained?
I'm using AssetDatabase.RenameAsset
to rename a folder, which effectively moves the assets inside it to the new path. I'm registering the operation with Undo.RegisterCompleteObjectUndo
(before) and EditorUtility.SetDirty
(after) on the folder and its contents, but it doesn't work. I also tried registering only the folder.
When I perform the undo, only the folder is renamed back to the original name, but the contents are still in the original path, which results in 2 folders.
How can I achieve this? I don't know if registering a callback with Undo.undoRedoPerformed
which deletes itself (just for this operation) will work properly or break posterior undoable operations that can be done. There is no good example in Unity docs for this method.
Your answer
Follow this Question
Related Questions
How to support undo for objects in .asset files 1 Answer
How to allow Undo on project assets created with an editor script? 0 Answers
How to change an object's name inside an asset file? 0 Answers
RenameAsset does not change the name of asset in Project Window in Awake() or OnEnable() 1 Answer
How to undo AssetDatabase.CreateAsset? 0 Answers