【发布时间】:2018-08-13 18:56:25
【问题描述】:
我想将 itemChild 从父级移开,但父级总是与子级一起移动到新位置。为什么父母要跟随孩子的立场?我怎样才能移动孩子并将父母留在原地。 我的代码:
GameObject go = new GameObject("go");
go.transform.parent = GameObject.FindGameObjectWithTag("Canvas").transform;
itemChild.transform.SetParent(go.transform);
itemChild.transform.localPosition = new Vector2(itemChild.transform.position.x, itemChild.transform.position.y + 250);
【问题讨论】:
-
您的代码根本没有设置父母的位置。您需要提供父母搬家的证据。
标签: unity3d position transform parent-child