I developing card game, so today I’ve started to implement card view. I want my cards to be fake 3D like with z shifted masked layers like it implemented in Marvel Snap. I’ve decided to use SpriteRenderer instead of world space canvases because I think SpriteRenderer is better suits in my case.
I’ve faced a very common problem (as I can judge from searching here in there on forum). As you can see on screens I have sprite sorting issues which AFAIK related to camera sorting mode where, again AFAIK, the default mode is axis sorting where value is equal to Vector3.Up. So while camera change it’s view sorting result changes even if cards have obvious Z order.
Well, ok. I need just change those settings. But docs and most references on forum leads to built-in option which is Project Settings -> Graphics -> CameraSettings -> Transparency Sort Mode. But I use URP. Well, there should be setting somewhere on URP asset, at least common sense and numerous of replies on forum tells me so. No, there is no such a setting. But wait, it is exclusive for URP 2D. Well unity docs says there is also such a property on Camera API. And that is what I’ve finally used to fix that issue.
I have two questions:
Is there something I do wrong about building 3D card view?
Why unity every time decide where it should give an access to something and when it just hides things?
Three (3) primary ways that Unity draws / stacks / sorts / layers / overlays stuff:
In short, as far as the Standard Rendering Pipeline,
The default 3D Renderers draw stuff according to Z depth - distance from camera.
SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties
UI Canvas Renderers draw in linear transform sequence, like a stack of papers
If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:
identify what you are using
search online for the combination of things you are doing and how to to achieve what you want.
There may be more than one solution to try.
For instance, you may even use multiple co-located cameras (along with different Layers and LayerMasks drawn to different-depth Cameras) to more-explicitly control apparent draw ordering.
Additional reading in the official docs:
And SortingGroups can also be extremely helpful in certain circumstances:
Other rendering pipelines may have other ways of layering (HDRP and URP). Go see the latest docs for details.
There’s lots of third party open source packages available as well, such as this: