- Home /
is it possible to undo DetachChildren() ?
Hi all,
Is it possible to undo DetachChildren() method?
I do DetachChildren() for all the selected objects and it is not effected via CTRL+Z.
This question sounds strange to me.. if you are in PlayMode, just stop the execution to return to the initial values of the scene..
If, on the other hand, you are in EditorMode, and you called the method via an editor script, just close the scene and save the changes.
Hi, thanks for feedback.
I'm in EditorMode. I want to undo the execution of detach child. I set the shortcut for to detach all child from the selection and want to ability for undo this action. Close and re-open the scene isn't a rapid way for an edition.
Unfortunately I did no find the solution yet.
I don't think there is a "quick" solution to what you want to accomplish.. you could create a script that keeps track of the objects in the scene and its current relatives, and the previous situation (if different).. in this way, enabling one shortcut you can ask to return to the previous situation..
Answer by ianny_dev · Jul 17, 2021 at 06:15 PM
The solution is to prevent to use DetachChildren(), and use SetTransformParent(Transform transform, Transform newParent, string name);
All was simple. As always :)
Your answer
Follow this Question
Related Questions
Displayed parent position moves with child? 1 Answer
Raycast Layermask doesn't ignore no layered Parent? 1 Answer
How to create youtube 360 vr flat cardboard behaviour in unity 2 Answers
How to make the child follow the parent's rotation 0 Answers
Missiles attached with FixedJoint cause too much torque for airplane physics 1 Answer