Version: 2021.3
public float width ;

描述

矩形的宽度(从 X 位置进行测量)。

设置此属性也会更改 xMax

using UnityEngine;

public class RectExample : MonoBehaviour { // Use this for initialization void Start() { Rect rect = new Rect(10, 10, 50, 30); Debug.Log("width = " + rect.width); // prints: width = 50 rect.width = 20; Debug.Log("new max x = " + rect.xMax); // prints: new max x = 30 } }