Create
7/14/25Less than 1 minute
Sprite.Create(Texture2D texture, Rect rect, Vector2 pivot, number pixelsPerUnit)
Create a new Sprite object.
Parameters:
| Name | Type | Description |
|---|---|---|
| texture | Texture2D | The Texture to obtain the Sprite graphic from. |
| rect | Rect | The rectangular section of the Texture to use for the Sprite. |
| pivot | Vector2 | The Sprite's pivot point relative to its graphic rectangle. |
| pixelsPerUnit | number | The number of pixels in the Sprite that correspond to one unit in world space. |
Returns:
| type | Description |
|---|---|
| Sprite | new Sprite object. |
Usage
---@type Texture2D
local texture;
---@type Rect
local rect;
---@type Vector2
local pivot;
---@type number
local pixelsPerUnit;
local val0 = Sprite:Create(texture, rect, pivot, pixelsPerUnit)Type/index.html) |The type of mesh that is generated for the Sprite. |
|border | Vector4 |The border sizes of the Sprite (X=left, Y=bottom, Z=right, W=top). |
Returns:
| type | Description |
|---|---|
| Sprite | new Sprite object. |
Usage
---@type Texture2D
local texture;
---@type Rect
local rect;
---@type Vector2
local pivot;
---@type number
local pixelsPerUnit;
---@type number
local extrude;
---@type SpriteMeshType
local meshType;
---@type Vector4
local border;
local val0 = Sprite:Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType, border)PerUnit;
---@type number
local extrude;
---@type SpriteMeshType
local meshType;
---@type Vector4
local border;
---@type boolean
local generateFallbackPhysicsShape;
local val0 = Sprite:Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType, border, generateFallbackPhysicsShape)

