using System; using System.Collections.Generic; using System.Reflection; namespace UnityEngine.Rendering { /// /// The abstract common implementation of the /// public abstract class DebugDisplaySettingsPanel : IDebugDisplaySettingsPanelDisposable { private readonly List m_Widgets = new List(); private readonly DisplayInfoAttribute m_DisplayInfo; /// /// The Panel name /// public virtual string PanelName => m_DisplayInfo?.name ?? string.Empty; /// /// The order where this panel should be shown /// public virtual int Order => m_DisplayInfo?.order ?? 0; /// /// The collection of widgets that are in this panel /// public DebugUI.Widget[] Widgets => m_Widgets.ToArray(); /// /// The for this panel /// public virtual DebugUI.Flags Flags => DebugUI.Flags.None; /// /// Adds a widget to the panel /// /// The to be added. protected void AddWidget(DebugUI.Widget widget) { if (widget == null) throw new ArgumentNullException(nameof(widget)); m_Widgets.Add(widget); } /// /// Clears the widgets list /// protected void Clear() { m_Widgets.Clear(); } /// /// Disposes the panel /// public virtual void Dispose() { Clear(); } /// /// Default constructor /// protected DebugDisplaySettingsPanel() { m_DisplayInfo = GetType().GetCustomAttribute(); if (m_DisplayInfo == null) Debug.Log($"Type {GetType()} should specify the attribute {nameof(DisplayInfoAttribute)}"); } } /// /// Class to help declare rendering debugger panels /// /// The type of Debug Display Settings Data that a Rendering Debugger Panel is using. public abstract class DebugDisplaySettingsPanel : DebugDisplaySettingsPanel where T : IDebugDisplaySettingsData { internal T m_Data; /// /// Access to the data stored /// public T data { get => m_Data; internal set => m_Data = value; } /// /// Default constructor /// /// The data that the panel holds protected DebugDisplaySettingsPanel(T data) : base() { m_Data = data; } } }