Sorting
Controlling render order of the NSliceSpriteRenderer
Sorting
The rendering order of objects is crucial in 2D games. NSliceSpriteRenderer uses Unity's standard Sprite Sorting system to control rendering order.
Sorting System Overview
In Unity's 2D rendering, rendering priority is determined in the following order:
- Sorting Layer (highest priority)
- Order in Layer (within the same Sorting Layer)
- Z Position (distance from camera)
Sorting Layer
Configuration
- Dropdown Menu: Select from a list of predefined Sorting Layers
- Default Value: "Default"
- Add Layer Button: Allows you to add new Sorting Layers
Performance Considerations
Draw Call Optimization
Objects with the same Sorting Layer and Order in Layer:
- Can be batched when using the same texture
- Reduces draw calls to improve performance
Recommendations
- Minimize Layers: Create only as many Sorting Layers as needed
- Use Gaps in Order: Use gaps like 10, 20, 30... to allow for future insertions
- Maintain Consistency: Apply consistent layering rules throughout your project