Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Camera inspector to modify opaqueSortMode and transparencySortMode
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
[CustomEditor(typeof(Camera), true)]
public class CameraInspector : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
DrawSortMode();
}
private void DrawSortMode()
{
GUILayout.Space(6);
var cam = (Camera)target;
GUILayout.BeginVertical("box");
EditorGUI.BeginChangeCheck();
var opaqueSortMode = (OpaqueSortMode)EditorGUILayout.EnumPopup("OpaqueSortMode", cam.opaqueSortMode);
if (EditorGUI.EndChangeCheck())
{
cam.opaqueSortMode = opaqueSortMode;
EditorUtility.SetDirty(cam);
}
EditorGUI.BeginChangeCheck();
var transparencySortMode = (TransparencySortMode)EditorGUILayout.EnumPopup("TransparencySortMode", cam.transparencySortMode);
if (EditorGUI.EndChangeCheck())
{
cam.transparencySortMode = transparencySortMode;
EditorUtility.SetDirty(cam);
}
GUILayout.EndVertical();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment