Scripting API

Sprite

class in UnityEngine · UnityEngine.CoreModule · inherits from Object

15 of 29 of Unity's membersUnity's documentation
In Tassix

A rectangle of a texture drawn in 2D, with a pivot and a pixels-per-unit scale. Geometry is always the full rect (Tight meshes draw as FullRect for now); layouts match Unity (recorded in rendering_2d).

Properties 12

Vector4 border { get; }
Bounds bounds { get; }

Local bounds: the rect around the pivot, 0.1 deep (as in Unity).

bool packed { get; }
Vector2 pivot { get; }

The pivot in pixels from the rect's bottom-left corner.

float pixelsPerUnit { get; }
Rect rect { get; }
Texture2D texture { get; }
Rect textureRect { get; }
Vector2 textureRectOffset { get; }
ushort[] triangles { get; }
Vector2[] uv { get; }
Vector2[] vertices { get; }

Top-left, top-right, bottom-left, bottom-right.

Methods 3

static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsPerUnit = 100f, uint extrude = 0, SpriteMeshType meshType = SpriteMeshType.Tight, Vector4 border = default, bool generateFallbackPhysicsShape = false)
static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsPerUnit, uint extrude, SpriteMeshType meshType, Vector4 border)
static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsPerUnit, uint extrude, SpriteMeshType meshType)
static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsPerUnit, uint extrude)
static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsPerUnit)
static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot)
static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsPerUnit, uint extrude, SpriteMeshType meshType, Vector4 border, bool generateFallbackPhysicsShape, SecondarySpriteTexture[] secondaryTextures)
pivot
Normalized within the rect: (0.5, 0.5) is the center.
int GetSecondaryTextureCount()
int GetSecondaryTextures(SecondarySpriteTexture[] secondaryTexture)

Not in Tassix yet 14

AddScriptableObject GetPhysicsShape GetPhysicsShapeCount GetPhysicsShapePointCount GetScriptableObjects GetScriptableObjectsCount OverrideGeometry OverridePhysicsShape RemoveScriptableObjectAt SetScriptableObjectAt associatedAlphaSplitTexture packingMode packingRotation spriteAtlasTextureScale

Checked against Unity

Conformance scenarios that exercise it, recorded in Unity and compared event by event.