【2D】1. Sprite Renderer

Click to visit the official website sprite-Sprite , Sprite Renderer

The Sprite Renderer component is used for renderingelvesand control its visualization in 2D and 3D project scenes.

When creating a sprite ( GameObject > 2D Object > Sprite ), Unity automatically creates a game object with a Sprite Renderer component attached to it. This component can also be added to an existing game object via the Components menu ( Component > Rendering > Sprite Renderer ).

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-LzxcrT0p-1683080102902)(Unity-2D.assets/image-20230503095557723.png)]

Attributes Function
Sprite Defines the sprite texture this component should render to.
Click the little dot on the right to open the object picker window and choose from a list of available sprite resources.
Color Defines the vertex color of the sprite, used for coloring or recoloring the sprite's image.
Use the color picker to set the vertex color of the rendered sprite texture. See the Colors section below this table for examples.
Flip Flips the sprite texture along the selected axis. This doesn't flip the game object's transformed position.
Draw Mode Defines how the sprite scales when its size changes.
● Simple When the size changes, the whole image is scaled. [This is the default option]
● Sliced Select this mode if the sprite is a 9-slice sprite. Click to access Size
under this option
● Tiled By default, this mode causes the middle of a 9-slice sprite to tile rather than scale when the sprite size changes.
Use Tile Mode to control the sprite's tiling behavior. Click to access Size , Tile Mode
under this option
Mask Interaction Sets how the sprite renderer behaves when interacting with the sprite mask . See examples of the different options in the Mask Interaction section below.
● None The sprite renderer does not interact with any sprite masks in the scene. This is the default option.
● Visible Inside Mask The sprite is visible where the sprite mask covers the sprite, but not outside the mask.
● Visible Outside Mask Sprites are visible outside the sprite mask, but not inside the mask.
A sprite mask hides the part of the sprite it covers.
Sprite Sort Point Choose between the sprite's Center or its pivot point when calculating the distance between the sprite and the camera.
See the Sprite Sort Point section for more details.
Material Defines the material used to render sprite textures .
Additional Settings
Sorting Layer Sets the Sorting Layer for sprites , which is used to control sprite priority during rendering.
Select an existing sort layer from the drop-down box, or create a new sort layer.
Order In Layer Sets the rendering priority of the sprite within its sorting layer .
Lower-numbered sprites are rendered first, with higher-numbered sprites superimposed on top of the former.

Size

Enter new Width and Height values ​​for the sprite to scale the 9-slice sprite correctly. You can also use the Rectangular Transform component tool to scale sprites when applying the 9-slice attribute .

Tile Mode

  • Continuous: This is the default Tile Mode setting. In Continuous mode, the middle portion is tiled evenly as the sprite size changes.
  • Adaptive: In Adaptive mode, the sprite texture stretches when its size changes, similar to Simple mode. When the zoom size of the changed dimension reaches the Stretch Value, the middle part starts to tile.
    • Stretch Value : Use the slider to set a value between 0 and 1. The maximum value is 1, which means twice the scaling of the original sprite.

Guess you like

Origin blog.csdn.net/qq_30769437/article/details/130468510