The SpriteRenderer component is used to display images in 3D/2D scenes.
In the editor, you can conveniently view and set the properties of a sprite renderer:
Property Name | Property Type | Description |
---|---|---|
sprite | Sprite | A reference to the sprite to use |
width | Number | Width of the sprite renderer. If not customized by the developer, it defaults to the sprite's width (in world space units) |
height | Number | Height of the sprite renderer. If not customized by the developer, it defaults to the sprite's height (in world space units) |
color | Color | Color of the sprite |
flipX | Boolean | Whether to flip on the X-axis during rendering |
flipY | Boolean | Whether to flip on the Y-axis during rendering |
drawMode | SpriteDrawMode | Drawing mode, supports normal, nine-slice, and tiling modes |
maskInteraction | SpriteMaskInteraction | Mask type, used to specify whether the sprite needs masking and whether to show content inside or outside the mask when masked |
maskLayer | SpriteMaskLayer | The mask layer to which the sprite belongs, used to match with SpriteMask. Defaults to Everything, meaning it can mask with any SpriteMask |
material | Material | Material information for the sprite renderer |
priority | Number | Render priority of the sprite renderer. Lower values indicate higher priority. Defaults to 0 |
In the Hierarchy Panel, right-click -> 2D Object -> Sprite Renderer to quickly create a node containing a sprite renderer.