• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Datatypes

    Edit

    Rect

    The Rect datatype in Unity represents a rectangle defined by its position x, y, and size width, height. It's commonly used in 2D game development to manage areas, positions, and sizes within a game scene.

    Properties

    x

    number

    Retrieve or assign the x-coordinate of the Rect.

    y

    number

    Access or modify the y-coordinate of the Rect.

    Get or set the position of the Rect as a Vector2.

    Obtain or modify the center position of the Rect.

    Access the min point of the Rect.

    Get the max point of the Rect.

    width

    number

    Access or modify the width of the Rect.

    height

    number

    Retrieve or set the height of the Rect.

    Get or set the size of the Rect as a Vector2.

    xMin

    number

    Access the minimum x-coordinate of the Rect.

    yMin

    number

    Access the minimum y-coordinate of the Rect.

    xMax

    number

    Get the maximum x-coordinate of the Rect.

    yMax

    number

    Access the maximum y-coordinate of the Rect.

    Obtain a Rect instance positioned at the origin (0, 0) with zero width and height. This represents a point at the origin.

    Methods

    Set the position and size of the Rect.

    Parameters

    x

    number

    y

    number

    width

    number

    height

    number

    Returns

    void

    Check if a point is within the Rect.

    Parameters

    point
    Vector2

    Returns

    boolean

    Determine if the Rect overlaps with another Rect.

    Parameters

    other
    Rect

    Returns

    boolean

    Create a new Rect from minimum and maximum coordinates.

    Parameters

    xmin

    number

    ymin

    number

    xmax

    number

    ymax

    number

    Returns

    Convert normalized coordinates to a point within the Rect.

    Parameters

    rectangle
    Rect
    normalizedRectCoordinates
    Vector2

    Returns

    Convert a point within the Rect to normalized coordinates.

    Parameters

    rectangle
    Rect
    point
    Vector2

    Returns

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.