Size & Pivot
Managing object dimensions and pivot points in the NSliceSpriteRenderer
Size & Pivot
Size and pivot settings play a crucial role in ensuring N-Slice images are displayed correctly in NSliceSpriteRenderer. This page covers size and pivot-related configurations.
Size Settings
Size (X, Y)
Sets the actual size of the object in Unity units.
- X: Width
- Y: Height
- Units: Unity units (by default, 1 Unity unit = 1 meter)
Relationship with N-Slice:
- N-Slice corners and borders stretch appropriately according to the set size
- Setting too small a size may cause N-Slice borders to overlap
- Minimum size is determined by the border size of the N-Slice Data
Pixels Per Unit
An important setting that determines sprite resolution.
- Default Value: 100
- Meaning: Determines how many pixels to display per Unity unit
- Example: 100 means a 100x100 pixel image is displayed as 1x1 Unity units
Usage Tips:
- It's recommended to match the Pixels Per Unit setting of the original sprite
- Higher values make images appear smaller; lower values make them appear larger
- Using consistent values across your entire project is recommended for size consistency between UI and game objects
Pivot & Size Settings
Use Sprite Pivot
Determines whether to use the original sprite's pivot settings.
- When Checked: Uses the pivot point set in the original sprite
- When Unchecked: Uses center pivot
Pivot Effects:
- Object's rotation center point
- Reference point for scale transformations
- Position used as anchor point
⚠️ Important Warning
Size Adjustment in Scene View
Never adjust size by dragging directly in Scene View!
- Dragging in Scene View changes the Scale
- Scale changes cause N-Slice borders to stretch as well, leading to unintended results
- Always adjust size using the Size field in the Inspector
Correct Size Adjustment Method
✅ Correct Method: Use the Size field in Inspector
❌ Incorrect Method: Dragging in Scene View
- Changes Transform Scale
- Distorts N-Slice borders
Difference Between Scale vs Size
- Size: Only the center portion of N-Slice stretches while borders maintain original size (correct behavior)
- Scale: All parts stretch proportionally (breaks N-Slice)