Skip to content

API > Sprite


Sprite⚓︎

Sprite inherits from Object

Represents a Sprite object for use in 2D gameplay.

Members⚓︎

Properties⚓︎

Name Description
Sprite.associatedAlphaSplitTexturePropertyReadonly Property 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.borderPropertyReadonly Property Returns the border sizes of the Sprite.
Sprite.boundsPropertyReadonly Property Bounds of the Sprite, specified by its center and extents in world space units.
Sprite.packingModePropertyReadonly Property If Sprite is packed (see Sprite.packed), returns its SpritePackingMode.
Sprite.pivotPropertyReadonly Property Location of the Sprite's center point in the Rect on the original Texture, specified in pixels.
Sprite.pixelsPerUnitPropertyReadonly Property The number of pixels in the Sprite that correspond to one unit in world space. (Read Only)
Sprite.rectPropertyReadonly Property Location of the Sprite on the original Texture, specified in pixels.
Sprite.spriteAtlasTextureScalePropertyReadonly Property The Variant scale of Texture used by the Sprite. This is useful to check when a Variant SpriteAtlas is being used by Sprites.
Sprite.texturePropertyReadonly Property 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.textureRectPropertyReadonly Property Get the rectangle this Sprite uses on its Texture. Raises an exception if this Sprite is tightly packed in an atlas.
Sprite.textureRectOffsetPropertyReadonly Property 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.trianglesPropertyReadonly Property Returns a copy of the array containing Sprite mesh triangles.
Sprite.uvPropertyReadonly Property The base Texture coordinates of the Sprite mesh.
Sprite.verticesPropertyReadonly Property Returns a copy of the array containing Sprite mesh vertex positions.

Static Methods⚓︎

Name Description
Sprite.Create(texture, rect, pivot, pixelsPerUnit, extrude) Static fieldMethod Create a new Sprite object.
Sprite.Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType) Static fieldMethod Create a new Sprite object.
Sprite.Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType, border, generateFallbackPhysicsShape) Static fieldMethod Create a new Sprite object.
Sprite.Create(texture, rect, pivot, pixelsPerUnit, extrude, meshType, border) Static fieldMethod Create a new Sprite object.
Sprite.Create(texture, rect, pivot) Static fieldMethod Create a new Sprite object.
Sprite.Create(texture, rect, pivot, pixelsPerUnit) Static fieldMethod Create a new Sprite object.

Inherited Members⚓︎

Inherited Properties⚓︎

Name Description
Sprite.hideFlagsProperty Should the object be hidden, saved with the Scene or modifiable by the user?
Sprite.nameProperty The name of the object.

Inherited Methods⚓︎

Name Description
Sprite.GetInstanceID()Method 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.