DebugDisplaySettingsLighting.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using UnityEngine;
  2. using NameAndTooltip = UnityEngine.Rendering.DebugUI.Widget.NameAndTooltip;
  3. namespace UnityEngine.Rendering.Universal
  4. {
  5. class DebugDisplaySettingsLighting : IDebugDisplaySettingsData
  6. {
  7. internal DebugLightingMode DebugLightingMode { get; private set; }
  8. internal DebugLightingFeatureFlags DebugLightingFeatureFlagsMask { get; private set; }
  9. static class Strings
  10. {
  11. public static readonly NameAndTooltip LightingDebugMode = new() { name = "Lighting Debug Mode", tooltip = "Use the drop-down to select which lighting and shadow debug information to overlay on the screen." };
  12. public static readonly NameAndTooltip LightingFeatures = new() { name = "Lighting Features", tooltip = "Filter and debug selected lighting features in the system." };
  13. }
  14. internal static class WidgetFactory
  15. {
  16. internal static DebugUI.Widget CreateLightingDebugMode(DebugDisplaySettingsLighting data) => new DebugUI.EnumField
  17. {
  18. nameAndTooltip = Strings.LightingDebugMode,
  19. autoEnum = typeof(DebugLightingMode),
  20. getter = () => (int)data.DebugLightingMode,
  21. setter = (value) => { },
  22. getIndex = () => (int)data.DebugLightingMode,
  23. setIndex = (value) => data.DebugLightingMode = (DebugLightingMode)value
  24. };
  25. internal static DebugUI.Widget CreateLightingFeatures(DebugDisplaySettingsLighting data) => new DebugUI.BitField
  26. {
  27. nameAndTooltip = Strings.LightingFeatures,
  28. getter = () => data.DebugLightingFeatureFlagsMask,
  29. setter = (value) => data.DebugLightingFeatureFlagsMask = (DebugLightingFeatureFlags)value,
  30. enumType = typeof(DebugLightingFeatureFlags),
  31. };
  32. }
  33. private class SettingsPanel : DebugDisplaySettingsPanel
  34. {
  35. public override string PanelName => "Lighting";
  36. public SettingsPanel(DebugDisplaySettingsLighting data)
  37. {
  38. AddWidget(DebugDisplaySettingsCommon.WidgetFactory.CreateMissingDebugShadersWarning());
  39. AddWidget(new DebugUI.Foldout
  40. {
  41. displayName = "Lighting Debug Modes",
  42. isHeader = true,
  43. opened = true,
  44. children =
  45. {
  46. WidgetFactory.CreateLightingDebugMode(data),
  47. WidgetFactory.CreateLightingFeatures(data)
  48. }
  49. });
  50. }
  51. }
  52. #region IDebugDisplaySettingsData
  53. public bool AreAnySettingsActive => (DebugLightingMode != DebugLightingMode.None) || (DebugLightingFeatureFlagsMask != DebugLightingFeatureFlags.None);
  54. public bool IsPostProcessingAllowed => (DebugLightingMode != DebugLightingMode.Reflections && DebugLightingMode != DebugLightingMode.ReflectionsWithSmoothness);
  55. public bool IsLightingActive => true;
  56. public bool TryGetScreenClearColor(ref Color color)
  57. {
  58. return false;
  59. }
  60. public IDebugDisplaySettingsPanelDisposable CreatePanel()
  61. {
  62. return new SettingsPanel(this);
  63. }
  64. #endregion
  65. }
  66. }