Transparency sort mode not working in URP

I’m trying to sort my sprites in a 2D game with URP and Transparency Sort Mode set to Custom Axis 0,1,0. The Z sorting only works in the Scene view, not in the Game view. I tried to do what is explained here: Transparency Sort Mode and Lightweight Render Pipeline ?_ga=2.33709793.1917298031.1610550622-170523125.1537693866 but it doesn’t work.

I’ve tried to do it in 4 different ways:

  1. I went to Edit > Project Settings and changed the renderer to none so the camera settings would appear. then I changed it to Custom and set to 0,1,0. then I set the renderer back to URP.
  2. I set the renderer to URP then created a 2D Renderer Data asset and set its sort mode to custom and the axis to 0,1,0.
  3. I made a static script as explained in the link above to set the sort mode project-wide through script
  4. I made a monobehaviour script that I attached to the camera which applies the sort mode to the camera specifically.

None of these 4 method worked. If I use method 4 and debug.log the camera’s sort mode it tells me it is indeed set to custom, yet it doesn’t show it in the game view. I also tried reinstalling URP and recreating my renderer assets.

My sprite are still sorting fine in Scene view, but not in Game view.

How do I fix this?

5 Likes

The issue was solved.
For posterity, it was a bug with an asset that I as using. I contacted the developer of that asset and they solved the bug.

Just found this while Googling the same problem. Method 1 worked perfectly for me. But why is this option being hidden from URP users if it works?

1 Like

I had already done #1, but for me it didn’t work until I also did #2. I think if you are using URP and you want 2d sprite sorting to work this way, you have to do both.

1 Like

Note that when you’re using URP, this setting just moves to the renderer asset. If you open that up in the inspector you can see the settings for custom sort axis in there instead.

3 Likes

Thanks for the steps. I finally got it to work. Remember that sprites have to be on the same SortingLayer and have the same Order In Layer!

2 Likes

any idea what the bug actually was? or what asset was breaking this? I’ve tried all of the above and it’s not working for me for some reason

For the record, if you use Universal Render Pipeline Asset with 2D Renderer Data to control your sorting axis, both Camera.transparencySortAxis and GraphicsSettings.transparencySortAxis will not work. At least this is the case for me in Unity 2021.3
A walkaround is to create another Universal Render Pipeline Asset with 2D Renderer Data having a different sorting axis, and then assign the asset through GraphicsSettings.renderPipelineAsset

1 Like

Had the same problem, point 2 put me on almost the correct track. I’ve started a project with Universal 2D preset (so with URP).

Setting custom transparency sort mode in Project Settings didn’t work, but…
I’ve found the default Renderer 2D Data object by clicking the Default Renderer Pipeline asset in Project Settings > Graphics, and it showed in Inspector the Renderer 2D Data object it used. I’ve set the Transparency Sort Mode/Axis in that object and it worked like a charm :slight_smile:

PSA: For those using URP 3d with sprites having this issue, this solved it for me: