Files
com.misaki.hdrp-toon/Editor/MeterialEditor/UIScopes/SurfaceOptionsScope.cs
2025-05-22 22:28:48 +09:00

103 lines
5.0 KiB
C#

using Misaki.ShaderGUI;
using UnityEditor;
using UnityEngine;
using static Misaki.HdrpToon.UTSPropertyName.SurfaceOptions;
namespace Misaki.HdrpToon.Editor
{
internal class SurfaceOptionsScope : MaterialUIScope<ShaderGUIExpandable>
{
private static class Properties
{
public static MaterialProperty surfaceType;
public static MaterialProperty fogOnTransparent;
public static MaterialProperty alphaClipEnable;
public static MaterialProperty alphaClip;
public static MaterialProperty cullMode;
public static MaterialProperty doubleSidedNormalMode;
public static MaterialProperty shadingMode;
public static MaterialProperty materialType;
public static MaterialProperty pbrMode;
public static MaterialProperty hairBlendingTarget;
public static MaterialProperty surfaceFeatures;
}
private static class Styles
{
public static readonly GUIContent transparentModeText = new("Surface Type", "Controls the surface type of the material.");
public static readonly GUIContent fogOnTransparentText = new("Fog On Transparent", "Enable to apply fog effect on transparent objects.");
public static readonly GUIContent alphaClipEnableText = new("Alpha Clipping", "Enable alpha clipping.");
public static readonly GUIContent alphaClipText = new("Alpha Clipping Threshold", "Threshold for alpha clipping.");
public static readonly GUIContent cullingModeText = new("Culling Mode", "Controls the sides of polygons that should not be drawn (culled).");
public static readonly GUIContent doubleSidedNormalModeText = new("Double Sided Mode", "Controls the normal mode for double-sided rendering.");
public static readonly GUIContent shadingModeText = new("Shading Color Mode", "Specifies the shading grade mode.");
public static readonly GUIContent materialTypeText = new("Material Type", "Specifies the material type.");
public static readonly GUIContent pbrModeText = new("PBR Mode", "Specifies PBR model mode.");
public static readonly GUIContent hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair");
public static readonly GUIContent surfaceFeaturesText = new("Surface Features", "Specifies the surface features.");
}
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions;
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
public override void LoadMaterialProperties()
{
Properties.surfaceType = FindProperty(SURFACE_TYPE);
Properties.fogOnTransparent = FindProperty(FOG_ON_TRANSPARENT);
Properties.alphaClipEnable = FindProperty(ALPHA_CLIP_ENABLE);
Properties.alphaClip = FindProperty(ALPHA_CUTOFF);
Properties.cullMode = FindProperty(CULL_MODE);
Properties.doubleSidedNormalMode = FindProperty(DOUBLE_SIDED_NORMAL_MODE);
Properties.shadingMode = FindProperty(SHADING_MODE);
Properties.materialType = FindProperty(MATERIAL_TYPE);
Properties.pbrMode = FindProperty(PBR_MODE);
Properties.hairBlendingTarget = FindProperty(HAIR_BLENDING_TARGET);
Properties.surfaceFeatures = FindProperty(SURFACE_FEATURE);
}
protected override void DrawContent()
{
editor.ShaderProperty(Properties.surfaceType, Styles.transparentModeText);
using (new EditorGUI.IndentLevelScope())
{
if (Properties.surfaceType.GetBooleanValue())
{
editor.ShaderProperty(Properties.fogOnTransparent, Styles.fogOnTransparentText);
}
editor.ShaderProperty(Properties.cullMode, Styles.cullingModeText);
if (Properties.cullMode.intValue == 0)
{
using (new EditorGUI.IndentLevelScope())
{
editor.ShaderProperty(Properties.doubleSidedNormalMode, Styles.doubleSidedNormalModeText);
}
}
}
editor.ShaderProperty(Properties.alphaClipEnable, Styles.alphaClipEnableText);
if (Properties.alphaClipEnable.GetBooleanValue())
{
using var s = new EditorGUI.IndentLevelScope();
editor.ShaderProperty(Properties.alphaClip, Styles.alphaClipText);
}
editor.ShaderProperty(Properties.shadingMode, Styles.shadingModeText);
editor.ShaderProperty(Properties.materialType, Styles.materialTypeText);
editor.ShaderProperty(Properties.pbrMode, Styles.pbrModeText);
editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText);
editor.ShaderProperty(Properties.surfaceFeatures, Styles.surfaceFeaturesText);
}
}
}