9-slicing is a 2D technique that allows you to resize a spriteA 2D graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development. More info
See in Glossary without creating multiple sprites for all the different sizes.
To use 9-slicing, you create a sprite with nine sections. The different sections stretch or repeat in different ways to keep the sprite in proportion.
9-slicing is useful for creating patterns, walls, or floors in a 2D environment.
Note: You can only use a Box Collider 2D or Polygon Collider 2D component to add a collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary shape to a 9-sliced sprite. For more information, refer to 9-slice a sprite.
If you don’t use 9-slicing, the entire sprite stretches when you change its dimensions.
With 9-slicing, you can resize the sprite using sliced mode or tiled mode.
In sliced mode, the sprite does the following:
In tiled mode, the sprite does the following:
You can control how Unity repeats the texture across the resized sprite. For more information, refer to 9-slice a sprite.