Graphics > Custom Axis - For Universal Render Pipleline

Is it possible to access/edit the custom axis while using URP? If so, how?

1 Like

You can access it globally through:

If you want to set it on a per camera basis:

6 Likes

Is there any update on this? Removing the pipeline does not work any more.

This seems cumbersome, why not have URP show the transparency sort mode in the editor. Its easy enough to set in a script, but there should be consistency across all the renderers.

For Unity 2019.4 and URP 7.3.1, you can configure this in the 2D Renderer Data asset:

6042008--652976--upload_2020-7-1_14-31-41.png

This should be the same for Unity 2020.1 and the compatible URP package. This can still be configured per Camera as well.

Hopefully this will make it easier to configure this setting in URP!

4 Likes

Ah cool, the last time I was playing around with URP and the 2D renderer I had to set it in a script. I thought that it should be easy to put in the asset. This is perfect, its directly in the asset thank you.

How do i use this and how in particular do i use this with a selected camera?

Also can i use this with a mix of 2d and 3d? I want the 2d to be sorted but the 3d to work on the z.

The following is a global setting for all cameras.

If you want to set it on a per camera basis, you can create a Monobehaviour that sets the sort mode and axis on Start:

Technically, this is for sorting of transparent renderers, where SpriteRenderers and other 2D renderers generally use Materials with the Transparent queue for Alpha blending. 3D renderers generally use Materials with the Opaque queue and will not be sorted with the Transparency Sort Mode set but rather with the standard Z distance.

1 Like

Hi, is there a way to get this to work in the editor view also? Its works as expected for the camera view which is great but its hard to design/lay things out in the editor.

Thanks.

You can try using this script and adding the TransparencySortModeHelper component to your Camera GameObject.

using UnityEditor;
using UnityEngine;

[RequireComponent(typeof(Camera))]
public class TransparencySortModeHelper : MonoBehaviour
{
}

#if UNITY_EDITOR
[CustomEditor(typeof(TransparencySortModeHelper))]
public class TransparencySortModeHelperEditor : Editor
{
    public override void OnInspectorGUI()
    {
        var camera = (target as TransparencySortModeHelper).GetComponent<Camera>();
        EditorGUI.BeginChangeCheck();
        var sortMode = (TransparencySortMode) EditorGUILayout.EnumPopup("Sort Mode", camera.transparencySortMode);
        var sortAxis = EditorGUILayout.Vector3Field("Sort Axis", camera.transparencySortAxis);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(camera, "Change Sort");
            camera.transparencySortMode = sortMode;
            camera.transparencySortAxis = sortAxis;
        }
    }
}
#endif
2 Likes

Hi All, I have been trying to get transparency sort mode to work with URP in unity 2019.4.3f1 with the 2DRenderer. I set my settings to custom axis with y=1 in my 2d renderer settings and have added two 2d sprite objects to the scene. The camera is in orthographic mode if that makes a difference. They don’t seem to swap when I drag them up and down over each other, one is always on top. Am I missing something here? The sprites are using the sprites/default shader.

Update: Upon further investigation I am able to get this to work by using a script to update the transparency sort mode settings. But just changing it in the 2d renderer data settings doesn’t seem to actually set the value. I can see in my source control that it is updating my 2DRenderer.asset but the GraphicsSettings.asset does not change, it keeps with whatever my script had set last, even after deleting the script.

2 Likes

+1 for this, your update is the trick that saved the day!

1 Like

Thank you I couldn’t find this option, I didn’t know you could change it via script !

For those who are stuck on this, I think it’s a bug in Unity. I made a report and will link here

EDIT: Link to Issue in issue tracker: Unity Issue Tracker - SRP Object Transparency Sort Mode/Sort Axis is not changed when setting the values in the 2D Renderer Data

I think the Camera Orthographic Setting is putting the TransparencySortMode = Default and the TransparencySortAxis = 0,0,1, even if you specify it to be TransparencySortMode = CustomAxis and TransparencySortAxis = 0,1,0 in the 2DRender object.

Spiraseven is right, this needs to be set in script.
Simplest script I could make. Attach this to the Camera you want the Topdown Sorting

    public class TransparencySortModeFixer : MonoBehaviour
    {
        private void Start()
        {
            cam = GetComponent<Camera>();
            Debug.Log("TRANSPARENCY SORTING");
            Debug.Log("Current Sort Mode:" + cam.transparencySortMode);
            Debug.Log("Current Sort Axis:" + cam.transparencySortAxis);
            cam.transparencySortAxis = Vector3.up;
            cam.transparencySortMode = TransparencySortMode.CustomAxis;
            Debug.Log("New Sort Mode:" + cam.transparencySortMode);
            Debug.Log("New Sort Axis:" + cam.transparencySortAxis);
        }
    }

Note: this does NOT work in the editor, only play mode!

2 Likes

Thanks, this helped me a lot. You can add [ExecuteInEditMode] to the top of your class so it will work in editor. Still only works in game view.

1 Like

If someone else needs help on this, im on 2020.3 and this works: remove the asset, change your custom axis, close unity, reopen unity, change the asset back.

2 Likes