Updated OutlineScope;
Reorgnize shader code;
This commit is contained in:
@@ -2,12 +2,16 @@ using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName.Outline;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class OutlineScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty outlineState;
|
||||
|
||||
public static MaterialProperty outlineWidth;
|
||||
public static MaterialProperty outlineWidthMap;
|
||||
|
||||
@@ -25,6 +29,8 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent outlineStateText = new("Outline State", "Enable the outline pass for this material instance.");
|
||||
|
||||
public static readonly GUIContent outlineWidthText = new("Outline Width", "Specifies the width of the outline.");
|
||||
public static readonly GUIContent outlineColorText = new("Outline Color", "Specifies the color of the outline.");
|
||||
public static readonly GUIContent albedoAffectOutlineText = new("Albedo Affect Outline", "Enable to affect the outline color with the albedo color.");
|
||||
@@ -36,37 +42,43 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static readonly GUIContent useSmoothedNormalText = new("Use Smoothed Normal", "Enable to use smoothed normal(that packed in uv2) for outline calculation.");
|
||||
}
|
||||
|
||||
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.Outline);
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Outline;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Outline Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.outlineWidth = FindProperty("_OutlineWidth");
|
||||
Properties.outlineWidthMap = FindProperty("_OutlineWidthMap");
|
||||
Properties.outlineState = FindProperty(OUTLINE_STATE);
|
||||
|
||||
Properties.outlineColor = FindProperty("_OutlineColor");
|
||||
Properties.outlineColorMap = FindProperty("_OutlineColorMap");
|
||||
Properties.albedoAffectOutline = FindProperty("_AlbedoAffectOutline");
|
||||
Properties.skyColorAffectOutline = FindProperty("_SkyColorAffectOutline");
|
||||
Properties.skyColorIntensity = FindProperty("_SkyColorIntensity");
|
||||
Properties.outlineWidth = FindProperty(OUTLINE_WIDTH);
|
||||
Properties.outlineWidthMap = FindProperty(OUTLINE_WIDTH_MAP);
|
||||
|
||||
Properties.fadeIn = FindProperty("_OutlineFadeIn");
|
||||
Properties.fadeOut = FindProperty("_OutlineFadeOut");
|
||||
Properties.outlineColor = FindProperty(OUTLINE_COLOR);
|
||||
Properties.outlineColorMap = FindProperty(OUTLINE_COLOR_MAP);
|
||||
Properties.albedoAffectOutline = FindProperty(ALBEDO_AFFECT_OUTLINE);
|
||||
Properties.skyColorAffectOutline = FindProperty(SKY_COLOR_AFFECT_OUTLINE);
|
||||
Properties.skyColorIntensity = FindProperty(SKY_COLOR_INTENSITY);
|
||||
|
||||
Properties.useSmoothedNormal = FindProperty("_UseSmoothedNormal");
|
||||
Properties.fadeIn = FindProperty(OUTLINE_FADE_IN);
|
||||
Properties.fadeOut = FindProperty(OUTLINE_FADE_OUT);
|
||||
|
||||
Properties.useSmoothedNormal = FindProperty(USE_SMOOTHED_NORMAL);
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.outlineState, Styles.outlineStateText);
|
||||
|
||||
using var disabledScope = new EditorGUI.DisabledScope(!Properties.outlineState.GetBooleanValue());
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth);
|
||||
editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor);
|
||||
editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText);
|
||||
editor.ShaderProperty(Properties.skyColorAffectOutline, Styles.skyColorAffectOutlineText);
|
||||
if (Properties.skyColorAffectOutline.GetBooleanValue())
|
||||
{
|
||||
using var skyColorIndentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
editor.ShaderProperty(Properties.skyColorIntensity, Styles.skyColorIntensityText);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user