9
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Unity] uGUIでStretch設定の Recttransformのサイズを変更する

Last updated at Posted at 2018-05-25

Stretch設定ではないRecttransformのサイズ変更はマニュアルに書いてあります
RectTransform.sizeDelta

Stretch設定の場合はRectTransform.OffSetMax,RectTransform.OffSetMinを編集すればサイズが変えられるのですが、
left,top,right,bottomとの対応がよくわかりません。
stretchedRectransform.jpg

そういうわけで分かるようにメソッドにしておきました。

    public static void SetStretchedRectOffset(RectTransform rectT, float left, float top, float right, float bottom) {
        rectT.offsetMin = new Vector2(left, bottom);
        rectT.offsetMax = new Vector2(-right, -top);
    }

[参照: answers.unity.com] "Setting top and bottom on a RectTransform"

9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?