Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


x

The X coordinate of the rectangle.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public float x { get; set; }

Remarks

This value is the same as Rect.xMin, but setting it will move the rectangle rather than resize it.

Examples

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