DebugDisplaySettingsCommon.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace UnityEngine.Rendering.Universal
  4. {
  5. class DebugDisplaySettingsCommon : IDebugDisplaySettingsData
  6. {
  7. internal static class WidgetFactory
  8. {
  9. internal static DebugUI.Widget CreateMissingDebugShadersWarning() => new DebugUI.MessageBox
  10. {
  11. displayName = "Warning: the debug shader variants are missing. Ensure that the \"Strip Debug Variants\" option is disabled in URP Global Settings.",
  12. style = DebugUI.MessageBox.Style.Warning,
  13. isHiddenCallback = () =>
  14. {
  15. #if UNITY_EDITOR
  16. return true;
  17. #else
  18. if (UniversalRenderPipelineGlobalSettings.instance != null)
  19. return !UniversalRenderPipelineGlobalSettings.instance.stripDebugVariants;
  20. return true;
  21. #endif
  22. }
  23. };
  24. }
  25. private class SettingsPanel : DebugDisplaySettingsPanel
  26. {
  27. public override string PanelName => "Frequently Used";
  28. const string k_GoToSectionString = "Go to Section...";
  29. public SettingsPanel()
  30. {
  31. AddWidget(DebugDisplaySettingsCommon.WidgetFactory.CreateMissingDebugShadersWarning());
  32. var materialSettingsData = DebugDisplaySettings.Instance.MaterialSettings;
  33. AddWidget(new DebugUI.Foldout
  34. {
  35. displayName = "Material Filters",
  36. isHeader = true,
  37. opened = true,
  38. children =
  39. {
  40. DebugDisplaySettingsMaterial.WidgetFactory.CreateMaterialOverride(materialSettingsData)
  41. },
  42. contextMenuItems = new List<DebugUI.Foldout.ContextMenuItem>()
  43. {
  44. new DebugUI.Foldout.ContextMenuItem
  45. {
  46. displayName = k_GoToSectionString,
  47. action = () => { DebugManager.instance.RequestEditorWindowPanelIndex(1); }
  48. }
  49. }
  50. });
  51. var lightingSettingsData = DebugDisplaySettings.Instance.LightingSettings;
  52. AddWidget(new DebugUI.Foldout
  53. {
  54. displayName = "Lighting Debug Modes",
  55. isHeader = true,
  56. opened = true,
  57. children =
  58. {
  59. DebugDisplaySettingsLighting.WidgetFactory.CreateLightingDebugMode(lightingSettingsData),
  60. DebugDisplaySettingsLighting.WidgetFactory.CreateLightingFeatures(lightingSettingsData)
  61. },
  62. contextMenuItems = new List<DebugUI.Foldout.ContextMenuItem>()
  63. {
  64. new DebugUI.Foldout.ContextMenuItem
  65. {
  66. displayName = k_GoToSectionString,
  67. action = () => { DebugManager.instance.RequestEditorWindowPanelIndex(2); }
  68. }
  69. }
  70. });
  71. var renderingSettingsData = DebugDisplaySettings.Instance.RenderingSettings;
  72. AddWidget(new DebugUI.Foldout
  73. {
  74. displayName = "Rendering Debug",
  75. isHeader = true,
  76. opened = true,
  77. children =
  78. {
  79. DebugDisplaySettingsRendering.WidgetFactory.CreateHDR(renderingSettingsData),
  80. DebugDisplaySettingsRendering.WidgetFactory.CreateMSAA(renderingSettingsData),
  81. DebugDisplaySettingsRendering.WidgetFactory.CreatePostProcessing(renderingSettingsData),
  82. DebugDisplaySettingsRendering.WidgetFactory.CreateAdditionalWireframeShaderViews(renderingSettingsData),
  83. DebugDisplaySettingsRendering.WidgetFactory.CreateWireframeNotSupportedWarning(renderingSettingsData),
  84. DebugDisplaySettingsRendering.WidgetFactory.CreateOverdraw(renderingSettingsData)
  85. },
  86. contextMenuItems = new List<DebugUI.Foldout.ContextMenuItem>()
  87. {
  88. new DebugUI.Foldout.ContextMenuItem
  89. {
  90. displayName = k_GoToSectionString,
  91. action = () => { DebugManager.instance.RequestEditorWindowPanelIndex(3); }
  92. }
  93. }
  94. });
  95. }
  96. }
  97. #region IDebugDisplaySettingsData
  98. public bool AreAnySettingsActive => DebugDisplaySettings.Instance.AreAnySettingsActive;
  99. public bool IsPostProcessingAllowed => DebugDisplaySettings.Instance.IsPostProcessingAllowed;
  100. public bool IsLightingActive => DebugDisplaySettings.Instance.IsLightingActive;
  101. public bool TryGetScreenClearColor(ref Color color) => DebugDisplaySettings.Instance.TryGetScreenClearColor(ref color);
  102. public IDebugDisplaySettingsPanelDisposable CreatePanel()
  103. {
  104. return new SettingsPanel();
  105. }
  106. #endregion
  107. }
  108. }