Sprite
info
Sprite inherits from Object
Represents a Sprite object for use in 2D gameplay.
Members
Properties
Name | Description |
---|---|
Sprite .associatedAlphaSplitTexture | Returns the Texture that contains the alpha channel from the source Texture. Unity generates this Texture under the hood for Sprites that have alpha in the source, and need to be compressed using techniques like ETC1. |
Sprite .border | Returns the border sizes of the Sprite. |
Sprite .bounds | Bounds of the Sprite, specified by its center and extents in world space units. |
Sprite .packingMode | If Sprite is packed (see Sprite.packed), returns its SpritePackingMode. |
Sprite .pivot | Location of the Sprite's center point in the Rect on the original Texture, specified in pixels. |
Sprite .pixelsPerUnit | The number of pixels in the Sprite that correspond to one unit in world space. (Read Only) |
Sprite .rect | Location of the Sprite on the original Texture, specified in pixels. |
Sprite .spriteAtlasTextureScale | The Variant scale of Texture used by the Sprite. This is useful to check when a Variant SpriteAtlas is being used by Sprites. |
Sprite .texture | Get the reference to the used Texture. If packed this will point to the atlas, if not packed will point to the source Sprite. |
Sprite .textureRect | Get the rectangle this Sprite uses on its Texture. Raises an exception if this Sprite is tightly packed in an atlas. |
Sprite .textureRectOffset | Gets the offset of the rectangle this Sprite uses on its Texture to the original Sprite bounds. If Sprite mesh type is FullRect, offset is zero. |
Sprite .triangles | Returns a copy of the array containing Sprite mesh triangles. |
Sprite .uv | The base Texture coordinates of the Sprite mesh. |
Sprite .vertices | Returns a copy of the array containing Sprite mesh vertex positions. |
Static Methods
Name | Description |
---|---|
Sprite .Create(texture, rect, pivot, pixelsPerUnit, extrude) | Create a new Sprite object. |
Sprite .Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType) | Create a new Sprite object. |
Sprite .Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType, border, generateFallbackPhysicsShape) | Create a new Sprite object. |
Sprite .Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType, border) | Create a new Sprite object. |
Sprite .Create(texture, rect, pivot) | Create a new Sprite object. |
Sprite .Create(texture, rect, pivot, pixelsPerUnit) | Create a new Sprite object. |
Inherited Members
Inherited Properties
Name | Description |
---|---|
Sprite .hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
Sprite .name | The name of the object. |
Inherited Methods
Name | Description |
---|---|
Sprite .GetInstanceID() | Returns the instance id of the object. |
Extra Detail
prites are 2D graphic objects used for characters, props, projectiles and other elements of 2D gameplay. The graphics are obtained from bitmap images - Texture2D. The Sprite class primarily identifies the section of the image that should be used for a specific Sprite. This information can then be used by a SpriteRenderer component on a GameObject to actually display the graphic.