2D

Sprite Renderer

The SpriteRenderer component is used to display images in 3D/2D scenes.

Properties

In the editor, you can conveniently view and set the properties of a sprite renderer:

image-20231007153753006
Property NameProperty TypeDescription
spriteSpriteA reference to the sprite to use
widthNumberWidth of the sprite renderer. If not customized by the developer, it defaults to the sprite's width (in world space units)
heightNumberHeight of the sprite renderer. If not customized by the developer, it defaults to the sprite's height (in world space units)
colorColorColor of the sprite
flipXBooleanWhether to flip on the X-axis during rendering
flipYBooleanWhether to flip on the Y-axis during rendering
drawModeSpriteDrawModeDrawing mode, supports normal, nine-slice, and tiling modes
maskInteractionSpriteMaskInteractionMask type, used to specify whether the sprite needs masking and whether to show content inside or outside the mask when masked
maskLayerSpriteMaskLayerThe mask layer to which the sprite belongs, used to match with SpriteMask. Defaults to Everything, meaning it can mask with any SpriteMask
materialMaterialMaterial information for the sprite renderer
priorityNumberRender priority of the sprite renderer. Lower values indicate higher priority. Defaults to 0
Render Priority, the distance between the bounding box and the camera, etc., collectively determine the rendering order of renderers. For details, see Render Order

Usage

In the Hierarchy Panel, right-click -> 2D Object -> Sprite Renderer to quickly create a node containing a sprite renderer.

avatar
Mask effects require the use of Sprite Mask

Was this page helpful?

On this page