「毎日Unity」の技術ブログ

開発で役立つ情報を発信する

【UnityC#】RectTransformのWidthとHeightの変更方法

RectTransformのWidthとHeightの変更方法をメモすることにしました。

[ 変更方法 ]

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScriptTest : MonoBehaviour
{
    private void Start()
    {
        float Width = 100;
        float Height = 100;

        transform.GetComponent<RectTransform>().sizeDelta = new Vector2(Width, Height);
    }
}