using System;
using NameAndTooltip = UnityEngine.Rendering.DebugUI.Widget.NameAndTooltip;
namespace UnityEngine.Rendering.HighDefinition
{
///
/// Decal-related Rendering Debugger settings.
///
class DebugDisplaySettingsDecal : IDebugDisplaySettingsData
{
internal DecalsDebugSettings m_Data = new DecalsDebugSettings();
/// Display the decal atlas.
public bool displayAtlas
{
get => m_Data.displayAtlas;
set => m_Data.displayAtlas = value;
}
/// Displayed decal atlas mip level.
public UInt32 mipLevel
{
get => m_Data.mipLevel;
set => m_Data.mipLevel = value;
}
static class Strings
{
public const string containerName = "Atlas Texture For Decals";
public static readonly NameAndTooltip displayAtlas = new() { name = "Display Atlas", tooltip = "Enable the checkbox to debug and display the decal atlas for a Camera in the top left of that Camera's view." };
public static readonly NameAndTooltip mipLevel = new() { name = "Mip Level", tooltip = "Use the slider to select the mip level for the decal atlas." };
}
[DisplayInfo(name = "Decals", order = 5)]
private class SettingsPanel : DebugDisplaySettingsPanel
{
public override string PanelName => "Decals";
public SettingsPanel(DebugDisplaySettingsDecal data)
{
AddWidget(new DebugUI.RuntimeDebugShadersMessageBox());
AddWidget(new DebugUI.Container()
{
displayName = Strings.containerName,
children =
{
new DebugUI.BoolField { nameAndTooltip = Strings.displayAtlas, getter = () => data.displayAtlas, setter = value => data.displayAtlas = value},
new DebugUI.UIntField
{
nameAndTooltip = Strings.mipLevel,
getter = () => data.mipLevel,
setter = value => data.mipLevel = value,
min = () => 0u,
max = () =>
{
int decalAtlasMipCountMax = RenderPipelineManager.currentPipeline is HDRenderPipeline hDRenderPipeline ?
hDRenderPipeline.GetDecalAtlasMipCount() : CoreUtils.GetMipCount(GlobalDecalSettings.k_DefaultAtlasSize);
return Convert.ToUInt32(decalAtlasMipCountMax);
},
isHiddenCallback = () => !data.displayAtlas
}
}
});
}
}
#region IDebugDisplaySettingsQuery
///
public bool AreAnySettingsActive => displayAtlas || mipLevel > 0;
///
public bool IsPostProcessingAllowed => !AreAnySettingsActive;
///
public bool IsLightingActive => !AreAnySettingsActive;
///
public bool TryGetScreenClearColor(ref Color color)
{
return false;
}
///
IDebugDisplaySettingsPanelDisposable IDebugDisplaySettingsData.CreatePanel()
{
return new SettingsPanel(this);
}
#endregion
}
}