-
Notifications
You must be signed in to change notification settings - Fork 855
Srp workflows - Debug panel system to core #5726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7701833
e70b1ea
2d6f7be
c1ad7ef
e48bb4c
ac3903c
d3c77d3
e998d1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace UnityEngine.Rendering | ||
{ | ||
/// <summary> | ||
/// Templated class for <see cref="IDebugDisplaySettings"/> | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class DebugDisplaySettings<T> : IDebugDisplaySettings | ||
where T : IDebugDisplaySettings, new() | ||
{ | ||
protected readonly HashSet<IDebugDisplaySettingsData> m_Settings = new HashSet<IDebugDisplaySettingsData>(); | ||
|
||
private static readonly Lazy<T> s_Instance = new Lazy<T>(() => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to clear the data when entering or exiting playmode? Note: When domain reload is not performed, the C# statics are not cleared and can contain invalid values. |
||
{ | ||
var instance = new T(); | ||
instance.Reset(); | ||
return instance; | ||
}); | ||
|
||
/// <summary> | ||
/// The singleton instance that contains the current settings of Rendering Debugger. | ||
/// </summary> | ||
public static T Instance => s_Instance.Value; | ||
|
||
#region IDebugDisplaySettingsQuery | ||
|
||
/// <summary> | ||
/// Returns true if any of the debug settings are currently active. | ||
/// </summary> | ||
public virtual bool AreAnySettingsActive | ||
{ | ||
get | ||
{ | ||
foreach (IDebugDisplaySettingsData setting in m_Settings) | ||
{ | ||
if (setting.AreAnySettingsActive) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Checks whether the current state of these settings allows post-processing. | ||
/// </summary> | ||
public virtual bool IsPostProcessingAllowed { get; } | ||
|
||
/// <summary> | ||
/// Returns true if lighting is active for current state of debug settings. | ||
/// </summary> | ||
public virtual bool IsLightingActive | ||
{ | ||
get | ||
{ | ||
bool lightingActive = true; | ||
foreach (IDebugDisplaySettingsData setting in m_Settings) | ||
lightingActive &= setting.IsLightingActive; | ||
return lightingActive; | ||
} | ||
} | ||
#endregion | ||
|
||
protected TData Add<TData>(TData newData) where TData : IDebugDisplaySettingsData | ||
{ | ||
m_Settings.Add(newData); | ||
return newData; | ||
} | ||
|
||
/// <summary> | ||
/// Executes an action for each element | ||
/// </summary> | ||
/// <param name="onExecute"></param> | ||
public void ForEach(Action<IDebugDisplaySettingsData> onExecute) | ||
{ | ||
foreach (IDebugDisplaySettingsData setting in m_Settings) | ||
{ | ||
onExecute(setting); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Reset the stored debug settings | ||
/// </summary> | ||
public virtual void Reset() | ||
{ | ||
m_Settings.Clear(); | ||
} | ||
|
||
/// <summary> | ||
/// Attempts to get the color that should be used to clear the screen according to current debug settings. | ||
/// </summary> | ||
/// <param name="color">A reference to the screen clear color to use.</param> | ||
/// <returns>True if the color reference was updated, and false otherwise.</returns> | ||
public virtual bool TryGetScreenClearColor(ref Color color) | ||
{ | ||
foreach (IDebugDisplaySettingsData setting in m_Settings) | ||
{ | ||
if (setting.TryGetScreenClearColor(ref color)) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace UnityEngine.Rendering.Universal | ||
namespace UnityEngine.Rendering | ||
{ | ||
public abstract class DebugDisplaySettingsPanel : IDebugDisplaySettingsPanelDisposable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class is disposable, although it can still be used while disposed. Is it intended? |
||
{ | ||
|
@@ -14,9 +14,14 @@ protected void AddWidget(DebugUI.Widget widget) | |
m_Widgets.Add(widget); | ||
} | ||
|
||
public void Dispose() | ||
protected void Clear() | ||
{ | ||
m_Widgets.Clear(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Clear(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace UnityEngine.Rendering | ||
{ | ||
/// <summary> | ||
/// Interface for storing the debug settings | ||
/// </summary> | ||
public interface IDebugDisplaySettings : IDebugDisplaySettingsQuery | ||
{ | ||
/// <summary> | ||
/// Reset the stored debug settings | ||
/// </summary> | ||
void Reset(); | ||
|
||
/// <summary> | ||
/// Executes an action for each element | ||
/// </summary> | ||
/// <param name="onExecute"></param> | ||
void ForEach(Action<IDebugDisplaySettingsData> onExecute); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should describe how to use the class. Like: "Subclass this to benefit for commonly used features regarding IDebugDisplaySettings"