【发布时间】:2018-09-05 22:50:28
【问题描述】:
我在单击按钮时统一调整 UI 面板的大小时遇到问题。我在左侧输入了一个负值,但是在我运行它之后它没有读取“-”值,我还想将面板的大小缩放到 1.24 这里是它的默认状态图片,在我执行代码之后以及我想要的样子。 很抱歉,我很难用文字来解释它,所以我只是把它编译成一张图片。
PS。我已经搜索了可以调整 Rect 比例但 Rect 消失的代码。
//Scaling left and right of the panel
DescriptionPanel.GetComponent<RectTransform>().offsetMax = new Vector2(-91.375f, -1);
DescriptionPanel.GetComponent<RectTransform>().offsetMin = new Vector2(76.295f, 0);
//Scaling x-axis of the panel when I include it in runtime my panel disappear so I did not include it in the picture below.
DescriptionPanel.GetComponent<RectTransform>().transform.localScale = new Vector2(1.24f, 1f);
更新 - 我已经修复了左右 RectTransform 问题。 剩下的问题是调整 rectTransform 的大小。 当我执行此代码时,我的面板消失了。我需要将 X 轴设置为 1.24。
DescriptionPanel.GetComponent<RectTransform>().transform.localScale = new Vector2(1.24f, 1f);
【问题讨论】:
标签: unity3d