暫無描述
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.

DebugDisplaySettingsLighting.cs 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using NameAndTooltip = UnityEngine.Rendering.DebugUI.Widget.NameAndTooltip;
  4. namespace UnityEngine.Rendering.Universal
  5. {
  6. /// <summary>
  7. /// Lighting-related Rendering Debugger settings.
  8. /// </summary>
  9. public class DebugDisplaySettingsLighting : IDebugDisplaySettingsData
  10. {
  11. /// <summary>
  12. /// Current debug lighting mode.
  13. /// </summary>
  14. public DebugLightingMode lightingDebugMode { get; set; }
  15. /// <summary>
  16. /// Current debug lighting feature flags mask that allows selective disabling individual lighting components.
  17. /// </summary>
  18. public DebugLightingFeatureFlags lightingFeatureFlags { get; set; }
  19. /// <summary>
  20. /// Current HDR debug mode.
  21. /// </summary>
  22. public HDRDebugMode hdrDebugMode { get; set; }
  23. static internal class Strings
  24. {
  25. 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." };
  26. public static readonly NameAndTooltip LightingFeatures = new() { name = "Lighting Features", tooltip = "Filter and debug selected lighting features in the system." };
  27. public static readonly NameAndTooltip HDRDebugMode = new() { name = "HDR Debug Mode", tooltip = "Select which HDR brightness debug information to overlay on the screen." };
  28. }
  29. internal static class WidgetFactory
  30. {
  31. internal static DebugUI.Widget CreateLightingDebugMode(SettingsPanel panel) => new DebugUI.EnumField
  32. {
  33. nameAndTooltip = Strings.LightingDebugMode,
  34. autoEnum = typeof(DebugLightingMode),
  35. getter = () => (int)panel.data.lightingDebugMode,
  36. setter = (value) => panel.data.lightingDebugMode = (DebugLightingMode)value,
  37. getIndex = () => (int)panel.data.lightingDebugMode,
  38. setIndex = (value) => panel.data.lightingDebugMode = (DebugLightingMode)value
  39. };
  40. internal static DebugUI.Widget CreateLightingFeatures(SettingsPanel panel) => new DebugUI.BitField
  41. {
  42. nameAndTooltip = Strings.LightingFeatures,
  43. getter = () => panel.data.lightingFeatureFlags,
  44. setter = (value) => panel.data.lightingFeatureFlags = (DebugLightingFeatureFlags)value,
  45. enumType = typeof(DebugLightingFeatureFlags),
  46. };
  47. internal static DebugUI.Widget CreateHDRDebugMode(SettingsPanel panel) => new DebugUI.EnumField
  48. {
  49. nameAndTooltip = Strings.HDRDebugMode,
  50. autoEnum = typeof(HDRDebugMode),
  51. getter = () => (int)panel.data.hdrDebugMode,
  52. setter = (value) => panel.data.hdrDebugMode = (HDRDebugMode)value,
  53. getIndex = () => (int)panel.data.hdrDebugMode,
  54. setIndex = (value) => panel.data.hdrDebugMode = (HDRDebugMode)value
  55. };
  56. }
  57. [DisplayInfo(name = "Lighting", order = 3)]
  58. internal class SettingsPanel : DebugDisplaySettingsPanel<DebugDisplaySettingsLighting>
  59. {
  60. public SettingsPanel(DebugDisplaySettingsLighting data)
  61. : base(data)
  62. {
  63. AddWidget(new DebugUI.RuntimeDebugShadersMessageBox());
  64. AddWidget(new DebugUI.Foldout
  65. {
  66. displayName = "Lighting Debug Modes",
  67. flags = DebugUI.Flags.FrequentlyUsed,
  68. isHeader = true,
  69. opened = true,
  70. children =
  71. {
  72. WidgetFactory.CreateLightingDebugMode(this),
  73. WidgetFactory.CreateHDRDebugMode(this),
  74. WidgetFactory.CreateLightingFeatures(this)
  75. }
  76. });
  77. }
  78. }
  79. #region IDebugDisplaySettingsData
  80. /// <inheritdoc/>
  81. public bool AreAnySettingsActive => (lightingDebugMode != DebugLightingMode.None) || (lightingFeatureFlags != DebugLightingFeatureFlags.None) || (hdrDebugMode != HDRDebugMode.None);
  82. /// <inheritdoc/>
  83. public bool IsPostProcessingAllowed => (lightingDebugMode != DebugLightingMode.Reflections && lightingDebugMode != DebugLightingMode.ReflectionsWithSmoothness);
  84. /// <inheritdoc/>
  85. public bool IsLightingActive => true;
  86. /// <inheritdoc/>
  87. IDebugDisplaySettingsPanelDisposable IDebugDisplaySettingsData.CreatePanel()
  88. {
  89. return new SettingsPanel(this);
  90. }
  91. #endregion
  92. }
  93. }