To keep a group of 2D GameObjects from mixing with another group of objects on the same sorting layers and sublayers, add the GameObjects to a sorting group.
For example, you can use this approach to keep multiple instances of the same prefab from mixing with each other, even if they use the same sorting layers and sublayers.
Follow these steps:
The sorting order remains the same, but all the child GameObjects now render on the sorting layer and sublayer of the Sorting Group component.
Note: Unity ignores the Distance to Camera property of each child GameObject. Unity calculates the distance based on the position of the GameObject that has the Sorting Group component.
You can nest sorting groups. A nested sorting group is sorted first, then sorted as a single item within the parent sorting group.
To move a nested sorting group to the top level of the hierarchy without moving it in the Hierarchy window, select the sorting group then set Sorting Type to Sort At Root.
In the following example, the sprites belong to the same Sorting Layer, but have different Order in Layer values. When you create a prefab from the hierarchy, the sprites from multiple prefab instances are on the same layers and can mix with each other.
If you add a sorting group, the prefab instances render correctly.
If mixing still occurs, set the Order in Layer value to a different value for each sorting group.