- Home /
Undo a instantiated gameObject Editor Script C#
I'm working on a Editor project that requires me to add game objects as children to a common parent object. This part I've accomplished but after i instantiate the game objects the Unity Undo (ctr z) wont remove the instantiated game object, thus my problem. I've been looking through the Unity Undo documentation to allow me to use the Unity undo function to remove any misplaced game objects. So far Undo.RegisterSceneUndo seems to be the only solution. Unfortunately it is slow and causes some problems with other background functions of my script.
I have also considered somehow making the parent game object a SerializedObject hoping it would remember its previous state and children but have had little success. If anyone has any ideas on how to accomplish this please let me know.
Thanks in advance.
Answer by RaptorClaw · Oct 10, 2013 at 09:04 PM
Stumbled across this problem myself use Undo.RegisterCreatedObjectUndo
For more detail check out step 14 of this awesome tutorial: http://hub.tutsplus.com/tutorials/how-to-add-your-own-tools-to-unitys-editor--active-10047
Your answer

Follow this Question
Related Questions
Manually creating Editor sometimes leads to NullReferenceException in SerializedObject constructor 0 Answers
Distribute terrain in zones 3 Answers
Changing Inspector's Serialized Property Label (With Code Sample) 1 Answer
Initialising List array for use in a custom Editor 1 Answer
Multiple Cars not working 1 Answer