[英]How can I change GameObjects location on the Hierarchy in [InitializeOnLoad] script type?
I mean that if in the Hierarchy I have some objects that are children this specific objects to move them to the main root. 我的意思是,如果在层次结构中,我有一些对象是子对象,则此特定对象会将它们移到主根。
For example let's say I have this Hierarchy tree: 例如,假设我有此层次结构树:
Cube1
Cube1
Cube1
Cube1
Cube1
Cube2
Cube3
The first Cube1 and the Cube2 are in the main root. 第一个Cube1和Cube2在主根目录中。 Now I want to move the 3 childs of the main Cube1 and Cube3 to the main root:
现在,我想将主Cube1和Cube3的3个子级移动到主根目录:
Cube1
Cube1
Cube1
Cube1
Cube1
Cube2
Cube3
The main goal is to move some specific objects from being children to the main root in the hierarchy. 主要目标是将某些特定对象从子级移到层次结构的主根。 Like when I'm dragging a gameobject to the main scene root to do it by script.
就像我将游戏对象拖到主场景根以通过脚本进行操作时一样。
如果我理解正确,那么您正在寻找的是:
transform.SetParent(null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.