当把孩子的位置设置为父母位置时,我遇到了问题。Gameobject的位置不能跟随父位置Unity
下面的截图:
我的脚本:
RightNext.transform.GetChild (0).gameObject.transform.SetParent (TemporaryPage.transform,false); // TemporaryPage = Cherry Cake
RightNext.transform.GetChild (0).GetComponent<RectTransform>().localScale = new Vector3 (1, 1, 1);
RightNext.transform.GetChild (0).gameObject.transform.parent = RightNext.transform;
RightNext.transform.GetChild (0).transform.position = RightNext.transform.position;
,我把它更新,以确保该位置没有发生变化。
为什么我的孩子的位置不在父母的内部和相同的位置,即使我已经将父母的位置设置为相同的位置?
感谢
丹尼斯
您的孩子对象位置是否设置为0? –
没有..当它被设置为0我在用什么? .Localposition还是.position? –
在儿童游戏物体的转换组件 –