No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DecalRendererFeatureEditor.cs 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using UnityEngine;
  2. using UnityEngine.Rendering;
  3. using UnityEngine.Rendering.Universal;
  4. namespace UnityEditor.Rendering.Universal
  5. {
  6. [CustomEditor(typeof(DecalRendererFeature))]
  7. internal class DecalSettings : Editor
  8. {
  9. private struct Styles
  10. {
  11. public static GUIContent Technique = EditorGUIUtility.TrTextContent("Technique", "This option determines what method is used for rendering decals.");
  12. public static GUIContent MaxDrawDistance = EditorGUIUtility.TrTextContent("Max Draw Distance", "Maximum global draw distance of decals.");
  13. public static GUIContent UseRenderingLayers = EditorGUIUtility.TrTextContent("Use Rendering Layers", "When enabled, you can configure specific Decal Projectors to affect only specific objects. The number of Rendering Layers affects the performance.");
  14. public static GUIContent SurfaceData = EditorGUIUtility.TrTextContent("Surface Data", "Allows specifying which decals surface data should be blended with surfaces.");
  15. public static GUIContent NormalBlend = EditorGUIUtility.TrTextContent("Normal Blend", "Controls the quality of normal reconstruction. The higher the value the more accurate normal reconstruction and the cost on performance.");
  16. }
  17. private SerializedProperty m_Technique;
  18. private SerializedProperty m_MaxDrawDistance;
  19. private SerializedProperty m_DecalLayers;
  20. private SerializedProperty m_DBufferSettings;
  21. private SerializedProperty m_DBufferSurfaceData;
  22. private SerializedProperty m_ScreenSpaceSettings;
  23. private SerializedProperty m_ScreenSpaceNormalBlend;
  24. private bool m_IsInitialized = false;
  25. private void Init()
  26. {
  27. if (m_IsInitialized)
  28. return;
  29. SerializedProperty settings = serializedObject.FindProperty("m_Settings");
  30. m_Technique = settings.FindPropertyRelative("technique");
  31. m_MaxDrawDistance = settings.FindPropertyRelative("maxDrawDistance");
  32. m_DecalLayers = settings.FindPropertyRelative("decalLayers");
  33. m_DBufferSettings = settings.FindPropertyRelative("dBufferSettings");
  34. m_DBufferSurfaceData = m_DBufferSettings.FindPropertyRelative("surfaceData");
  35. m_ScreenSpaceSettings = settings.FindPropertyRelative("screenSpaceSettings");
  36. m_ScreenSpaceNormalBlend = m_ScreenSpaceSettings.FindPropertyRelative("normalBlend");
  37. m_IsInitialized = true;
  38. }
  39. public override void OnInspectorGUI()
  40. {
  41. Init();
  42. EditorGUILayout.PropertyField(m_Technique, Styles.Technique);
  43. DecalTechniqueOption technique = (DecalTechniqueOption)m_Technique.intValue;
  44. if (technique == DecalTechniqueOption.DBuffer)
  45. {
  46. EditorGUI.indentLevel++;
  47. EditorGUILayout.PropertyField(m_DBufferSurfaceData, Styles.SurfaceData);
  48. EditorGUI.indentLevel--;
  49. }
  50. if (technique == DecalTechniqueOption.ScreenSpace)
  51. {
  52. EditorGUI.indentLevel++;
  53. EditorGUILayout.PropertyField(m_ScreenSpaceNormalBlend, Styles.NormalBlend);
  54. EditorGUI.indentLevel--;
  55. }
  56. EditorGUILayout.PropertyField(m_MaxDrawDistance, Styles.MaxDrawDistance);
  57. EditorGUILayout.PropertyField(m_DecalLayers, Styles.UseRenderingLayers);
  58. }
  59. }
  60. }