ForwardRendererDataEditor.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using UnityEngine;
  2. using UnityEngine.Rendering;
  3. using UnityEngine.Rendering.Universal;
  4. using UnityEngine.Scripting.APIUpdating;
  5. namespace UnityEditor.Rendering.Universal
  6. {
  7. [CustomEditor(typeof(ForwardRendererData), true)]
  8. [MovedFrom("UnityEditor.Rendering.LWRP")] public class ForwardRendererDataEditor : ScriptableRendererDataEditor
  9. {
  10. private static class Styles
  11. {
  12. public static readonly GUIContent RendererTitle = new GUIContent("Forward Renderer", "Custom Forward Renderer for Universal RP.");
  13. public static readonly GUIContent FilteringLabel = new GUIContent("Filtering", "Controls filter rendering settings for this renderer.");
  14. public static readonly GUIContent OpaqueMask = new GUIContent("Opaque Layer Mask", "Controls which opaque layers this renderer draws.");
  15. public static readonly GUIContent TransparentMask = new GUIContent("Transparent Layer Mask", "Controls which transparent layers this renderer draws.");
  16. public static readonly GUIContent defaultStencilStateLabel = EditorGUIUtility.TrTextContent("Default Stencil State", "Configure stencil state for the opaque and transparent render passes.");
  17. public static readonly GUIContent shadowTransparentReceiveLabel = EditorGUIUtility.TrTextContent("Transparent Receive Shadows", "When disabled, none of the transparent objects will receive shadows.");
  18. }
  19. SerializedProperty m_OpaqueLayerMask;
  20. SerializedProperty m_TransparentLayerMask;
  21. SerializedProperty m_DefaultStencilState;
  22. SerializedProperty m_PostProcessData;
  23. SerializedProperty m_Shaders;
  24. SerializedProperty m_ShadowTransparentReceiveProp;
  25. private void OnEnable()
  26. {
  27. m_OpaqueLayerMask = serializedObject.FindProperty("m_OpaqueLayerMask");
  28. m_TransparentLayerMask = serializedObject.FindProperty("m_TransparentLayerMask");
  29. m_DefaultStencilState = serializedObject.FindProperty("m_DefaultStencilState");
  30. m_PostProcessData = serializedObject.FindProperty("postProcessData");
  31. m_Shaders = serializedObject.FindProperty("shaders");
  32. m_ShadowTransparentReceiveProp = serializedObject.FindProperty("m_ShadowTransparentReceive");
  33. }
  34. public override void OnInspectorGUI()
  35. {
  36. serializedObject.Update();
  37. EditorGUILayout.Space();
  38. EditorGUILayout.LabelField(Styles.RendererTitle, EditorStyles.boldLabel); // Title
  39. EditorGUI.indentLevel++;
  40. EditorGUILayout.PropertyField(m_PostProcessData);
  41. EditorGUI.indentLevel--;
  42. EditorGUILayout.Space();
  43. EditorGUILayout.LabelField(Styles.FilteringLabel, EditorStyles.boldLabel);
  44. EditorGUI.indentLevel++;
  45. EditorGUILayout.PropertyField(m_OpaqueLayerMask, Styles.OpaqueMask);
  46. EditorGUILayout.PropertyField(m_TransparentLayerMask, Styles.TransparentMask);
  47. EditorGUI.indentLevel--;
  48. EditorGUILayout.Space();
  49. EditorGUILayout.LabelField("Shadows", EditorStyles.boldLabel);
  50. EditorGUI.indentLevel++;
  51. EditorGUILayout.PropertyField(m_ShadowTransparentReceiveProp, Styles.shadowTransparentReceiveLabel);
  52. EditorGUI.indentLevel--;
  53. EditorGUILayout.Space();
  54. EditorGUILayout.LabelField("Overrides", EditorStyles.boldLabel);
  55. EditorGUI.indentLevel++;
  56. EditorGUILayout.PropertyField(m_DefaultStencilState, Styles.defaultStencilStateLabel, true);
  57. EditorGUI.indentLevel--;
  58. EditorGUILayout.Space();
  59. serializedObject.ApplyModifiedProperties();
  60. base.OnInspectorGUI(); // Draw the base UI, contains ScriptableRenderFeatures list
  61. // Add a "Reload All" button in inspector when we are in developer's mode
  62. if (EditorPrefs.GetBool("DeveloperMode"))
  63. {
  64. EditorGUILayout.Space();
  65. EditorGUILayout.PropertyField(m_Shaders, true);
  66. if (GUILayout.Button("Reload All"))
  67. {
  68. var resources = target as ForwardRendererData;
  69. resources.shaders = null;
  70. ResourceReloader.ReloadAllNullIn(target, UniversalRenderPipelineAsset.packagePath);
  71. }
  72. }
  73. }
  74. }
  75. }