I'm working on an extension and I need to give the user a popup message (DisplayDialog) offering to undo the deletion of a GameObject if it is needed by the extension.
What I'm doing right now is counting the number of GameObjects in the scene when something in the scene changes from an Update method set to ExecuteInEditMode. If the number of GameObjects decreases, a dialog is displayed offering to undo. If the user clicks undo, Undo.PerformUndo() is called.
This should work in theory, but I'm getting the following error message when using Undo.PerformUndo() in the Update method:
PlayerLoop called recursively!
UnityEditor.Undo:PerformUndo()
It does not seem like Update is being called more than once, since it is set to ExecuteInEditMode. How can we solve this problem or can you think of a better solution?
↧