using Misaki.ShaderGUI; using UnityEditor; using UnityEngine; namespace Misaki.HdrpToon.Editor { internal class SurfaceOptionsScope : MaterialUIScope { private static class Properties { public static MaterialProperty transparentMode; public static MaterialProperty alphaClipEnable; public static MaterialProperty alphaClip; public static MaterialProperty cullMode; public static MaterialProperty materialType; public static MaterialProperty pbrMode; public static MaterialProperty receiveHairShadow; public static MaterialProperty hairBlendingTarget; } private static class Styles { public readonly static GUIContent transparentModeText = new("Transparent Mode", "Enable different modes that allow the simulation of a variety of transparent objects."); public readonly static GUIContent alphaClipEnableText = new("Alpha Clipping", "Enable alpha clipping."); public readonly static GUIContent alphaClipText = new("Alpha Clipping Threshold", "Threshold for alpha clipping."); public readonly static GUIContent cullingModeText = new("Culling Mode", "Controls the sides of polygons that should not be drawn (culled)."); 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 receiveHairShadowText = new("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster"); public static readonly GUIContent hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair"); } protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions; protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options"); public override void LoadMaterialProperties() { Properties.transparentMode = FindProperty("_TransparentEnabled"); Properties.alphaClipEnable = FindProperty("_AlphaCutoffEnable"); Properties.alphaClip = FindProperty("_AlphaCutoff"); Properties.cullMode = FindProperty("_CullMode"); Properties.materialType = FindProperty("_Material_Type"); Properties.pbrMode = FindProperty("_PBR_Mode"); Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow"); Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget"); } protected override void DrawContent() { editor.ShaderProperty(Properties.transparentMode, Styles.transparentModeText); editor.ShaderProperty(Properties.alphaClipEnable, Styles.alphaClipEnableText); if (Properties.alphaClipEnable.floatValue == 1.0f) { EditorGUI.indentLevel++; editor.ShaderProperty(Properties.alphaClip, Styles.alphaClipText); EditorGUI.indentLevel--; } editor.ShaderProperty(Properties.cullMode, Styles.cullingModeText); editor.ShaderProperty(Properties.materialType, Styles.materialTypeText); editor.ShaderProperty(Properties.pbrMode, Styles.pbrModeText); editor.ShaderProperty(Properties.receiveHairShadow, Styles.receiveHairShadowText); EditorGUI.BeginChangeCheck(); editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText); if (EditorGUI.EndChangeCheck()) { foreach (var material in GetMaterials()) { material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.floatValue == 1.0f); } } } } }