Skip to main content

Sprite

info

Sprite inherits from Object

Represents a Sprite object for use in 2D gameplay.

Members

Properties

NameDescription
Sprite.associatedAlphaSplitTextureReturns 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.borderReturns the border sizes of the Sprite.
Sprite.boundsBounds of the Sprite, specified by its center and extents in world space units.
Sprite.packingModeIf Sprite is packed (see Sprite.packed), returns its SpritePackingMode.
Sprite.pivotLocation of the Sprite's center point in the Rect on the original Texture, specified in pixels.
Sprite.pixelsPerUnitThe number of pixels in the Sprite that correspond to one unit in world space. (Read Only)
Sprite.rectLocation of the Sprite on the original Texture, specified in pixels.
Sprite.spriteAtlasTextureScaleThe Variant scale of Texture used by the Sprite. This is useful to check when a Variant SpriteAtlas is being used by Sprites.
Sprite.textureGet the reference to the used Texture. If packed this will point to the atlas, if not packed will point to the source Sprite.
Sprite.textureRectGet the rectangle this Sprite uses on its Texture. Raises an exception if this Sprite is tightly packed in an atlas.
Sprite.textureRectOffsetGets 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.trianglesReturns a copy of the array containing Sprite mesh triangles.
Sprite.uvThe base Texture coordinates of the Sprite mesh.
Sprite.verticesReturns a copy of the array containing Sprite mesh vertex positions.

Static Methods

NameDescription
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

NameDescription
Sprite.hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
Sprite.nameThe name of the object.

Inherited Methods

NameDescription
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.