如果我将对象分配为GameObject,则无法使RectTransform工作。如何解决?
我想通过这条代码来提供我的父gamobject 库存 spicific rec坐标: intectory.getComponent< recttransform>()
。继续将rec坐标更改为世界配音。我已经尝试将库存分配为A transform 和 recttransform ,但它说该类型中有一个失误。
如何通过修复我的代码或将其分配为不同的东西来解决该问题?
I want to give my Parent GameObject Inventory spicific rec-coordinates via this line of code:Inventory.GetComponent<RectTransform>().position = new Vector3(500f, 0f, 0f);
In the editor, the object Inventory is assigned as a GameObject, so it keeps changing the rec-coordinates to world-coordinates. I've tried assigning the Inventory as a Transform and RectTransform but it says that there is a missmatch in the type.
How can I fix that, either by fixing my code or by assigning it as something different?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
锚定
移动recttransform
对象。请记住,其变量采用
vector2
。Use
anchoredPosition
to moveRectTransform
object.Remember that its variable takes
Vector2
.您应该修改RectTransform的局部问题:
即使没有
recttransform
(localpositions似乎是在变换&amp; recttransform之间)的(localpositions):You should modify the RectTransform's localPosition:
Even without
RectTransform
(localPositions seems to be inherited/shared between Transform&RectTransform):