Struct Rect | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Struct Rect

    2D rectangle

    Namespace: Unity.Tiny.Core2D
    Syntax
    [IdAlias("f216da154c4054842adb590807e977ba")]
    public struct Rect

    Constructors

    Rect(Single, Single, Single, Single)

    Declaration
    public Rect(float x, float y, float width, float height)
    Parameters
    Type Name Description
    System.Single x
    System.Single y
    System.Single width
    System.Single height

    Fields

    height

    Declaration
    public float height
    Field Value
    Type Description
    System.Single

    width

    Declaration
    public float width
    Field Value
    Type Description
    System.Single

    x

    Declaration
    public float x
    Field Value
    Type Description
    System.Single

    y

    Declaration
    public float y
    Field Value
    Type Description
    System.Single

    Properties

    Center

    The position of the center of the rectangle.

    Declaration
    public float2 Center { get; set; }
    Property Value
    Type Description
    float2

    Default

    Default unit rectangle.

    Declaration
    public static Rect Default { get; }
    Property Value
    Type Description
    Rect

    Size

    The width and height of the rectangle.

    Declaration
    public float2 Size { get; set; }
    Property Value
    Type Description
    float2

    Methods

    Clamp(Rect)

    Declaration
    public void Clamp(Rect r)
    Parameters
    Type Name Description
    Rect r

    Contains(float2)

    Returns true if pos is inside this rectangle.

    Declaration
    public bool Contains(float2 pos)
    Parameters
    Type Name Description
    float2 pos
    Returns
    Type Description
    System.Boolean
    Remarks

    The left and bottom edges are inclusive, while the right and top edges are exclusive. Also, while this class doesn't forbid 0 or negative width / heights, Contains() will be always be false in that case.

    IsEmpty()

    Declaration
    public bool IsEmpty()
    Returns
    Type Description
    System.Boolean

    Region(Rect)

    Returns a new rectangle translated and scaled by relative.

    Declaration
    public Rect Region(in Rect relative)
    Parameters
    Type Name Description
    Rect relative
    Returns
    Type Description
    Rect

    Extension Methods

    UnityCore2DConversionExtensions.Convert(Rect)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023