【问题标题】:Unity Scaling rect transform left right and scale xunity Scaling rect 左右变换并缩放 x
【发布时间】: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


    【解决方案1】:

    在转换局部比例时您可能必须使用 Vector3,因为您的 DescriptionPanel 可能会移到画布后面

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多