Added ShadingColorScope;

This commit is contained in:
2025-01-30 22:36:37 +08:00
parent 181a53a3b2
commit 5d23bd906b
3 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
using Misaki.ShaderGUI;
using UnityEditor;
using UnityEngine;
namespace Misaki.HdrpToon.Editor
{
public class ShadingColorSettingsScope : MaterialUIScope<ShaderGUIExpandable>
{
private static class Properties
{
public static MaterialProperty baseColorMap;
public static MaterialProperty baseColor;
public static MaterialProperty applyTo1stShadingMapEnable;
public static MaterialProperty firstShadingMap;
public static MaterialProperty firstShadingColor;
public static MaterialProperty applyTo2ndShadingMapEnable;
public static MaterialProperty secondShadingMap;
public static MaterialProperty secondShadingColor;
}
private static class Styles
{
public static readonly GUIContent baseMapText = new("Base Map",
"Base Color : Texture(sRGB) x Color(RGB) Default:White");
public static readonly GUIContent applyTo1stShadingMapText =
new("Apply to 1st shading map", "Apply Base map to the 1st shading map.");
public static readonly GUIContent firstShadingMapText = new("1st Shading Map", "1st shading map.");
public static readonly GUIContent firstShadeColorText = new("1st Shading Color", "1st shading color.");
public static readonly GUIContent applyTo2ndShadingMapText =
new("Apply to 2nd shading map", "Apply Base map or the 1st shading map to the 2st shading map.");
public static readonly GUIContent secondShadingMapText = new("2nd Shading Map", "2nd shading map.");
public static readonly GUIContent secondShadeColorText = new("2nd Shading Color", "2nd shading color.");
}
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Basic;
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shading Color Settings");
public override void LoadMaterialProperties()
{
Properties.baseColorMap = FindProperty("_BaseColorMap");
Properties.baseColor = FindProperty("_BaseColor");
Properties.applyTo1stShadingMapEnable = FindProperty("_Use_BaseAs1st");
Properties.firstShadingMap = FindProperty("_1st_ShadeMap");
Properties.firstShadingColor = FindProperty("_1st_ShadeColor");
Properties.applyTo2ndShadingMapEnable = FindProperty("_Use_1stAs2nd");
Properties.secondShadingMap = FindProperty("_2nd_ShadeMap");
Properties.secondShadingColor = FindProperty("_2nd_ShadeColor");
}
protected override void DrawContent()
{
editor.TexturePropertySingleLine(Styles.baseMapText, Properties.baseColorMap, Properties.baseColor);
EditorGUI.indentLevel += 2;
EditorGUI.BeginChangeCheck();
bool applyToFirst = EditorGUILayout.Toggle(Styles.applyTo1stShadingMapText,
Properties.applyTo1stShadingMapEnable.floatValue != 0);
if (EditorGUI.EndChangeCheck())
{
editor.RegisterPropertyChangeUndo(Styles.applyTo1stShadingMapText.text);
Properties.applyTo1stShadingMapEnable.floatValue = applyToFirst ? 1 : 0;
}
EditorGUI.indentLevel -= 2;
if (applyToFirst)
{
EditorGUI.indentLevel += 2;
editor.ColorProperty(Properties.firstShadingColor, Styles.firstShadeColorText.text);
EditorGUI.indentLevel -= 2;
}
else
{
editor.TexturePropertySingleLine(Styles.firstShadingMapText, Properties.firstShadingMap,
Properties.firstShadingColor);
}
EditorGUI.indentLevel += 2;
EditorGUI.BeginChangeCheck();
bool applyToSecond = EditorGUILayout.Toggle(Styles.applyTo2ndShadingMapText,
Properties.applyTo2ndShadingMapEnable.floatValue != 0);
if (EditorGUI.EndChangeCheck())
{
editor.RegisterPropertyChangeUndo(Styles.applyTo2ndShadingMapText.text);
Properties.applyTo2ndShadingMapEnable.floatValue = applyToSecond ? 1 : 0;
}
EditorGUI.indentLevel -= 2;
if (applyToSecond)
{
EditorGUI.indentLevel += 2;
editor.ColorProperty(Properties.secondShadingColor, Styles.secondShadeColorText.text);
EditorGUI.indentLevel -= 2;
}
else
{
editor.TexturePropertySingleLine(Styles.secondShadingMapText, Properties.secondShadingMap,
Properties.secondShadingColor);
}
EditorGUILayout.Space();
editor.TextureScaleOffsetProperty(Properties.baseColorMap);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4434ff1451f044df8fdfbaddeb4ee13b
timeCreated: 1737690087

View File

@@ -25,6 +25,7 @@ namespace Misaki.HdrpToon.Editor
private void OnInitialize(MaterialEditor materialEditor, MaterialProperty[] properties)
{
AddUIScope(new SurfaceOptionsScope());
AddUIScope(new ShadingColorSettingsScope());
AddUIScope(new AngelRingScope());
AddUIScope(new OutlineScope());