Skip to content

Instantly share code, notes, and snippets.

@t-tutiya
Created May 13, 2018 01:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-tutiya/824ba6ccb05fb1d1d210aa4a4389ae03 to your computer and use it in GitHub Desktop.
Save t-tutiya/824ba6ccb05fb1d1d210aa4a4389ae03 to your computer and use it in GitHub Desktop.
//UnityChanShaderGUI_T2.shader
//ユニティちゃんシェーダー(Toon_DoubleShadeWithFeather)用エディタ拡張
//ver1.0(2018/10/13)
//作者:土屋つかさ
//本ソースコードはユニティちゃんライセンス(http://unity-chan.com/contents/license_jp/)に準じて配布されます。
using System;
using UnityEngine;
namespace UnityEditor
{
internal class UnityChanShaderGUI_T2 : ShaderGUI
{
private static class Styles
{
//
public static GUIContent CullModeText =
new GUIContent("Cull Mode");
//Surface
public static GUIContent BaseMapText =
new GUIContent("Base");
public static GUIContent BaseColorText =
new GUIContent("_BaseColor");
public static GUIContent LightColor =
new GUIContent("Use LightColor");
public static GUIContent NormalMap =
new GUIContent("Normal");
public static GUIContent Is_NormalMapToBaseText =
new GUIContent("_Is_NormalMapToBase");
//1st Shadow
public static GUIContent ShadeMap_1st_Text =
new GUIContent("Shade");
public static GUIContent ShadeColor_1st_Text =
new GUIContent("_1st_ShadeColor");
public static GUIContent Set_1st_ShadePositionText =
new GUIContent("Position");
public static GUIContent Is_LightColor_1st_ShadeText =
new GUIContent("Use LightColor");
public static GUIContent BaseColor_StepText =
new GUIContent("Step");
public static GUIContent BaseShade_FeatherText =
new GUIContent("Feather");
//2nd Shadow
public static GUIContent ShadeMap_2nd_Text =
new GUIContent("Shade");
public static GUIContent ShadeColor_2nd_Text =
new GUIContent("_2nd_ShadeColor");
public static GUIContent Set_2nd_ShadePositionText =
new GUIContent("Position");
public static GUIContent Is_LightColor_2nd_ShadeText =
new GUIContent("Use LightColor");
public static GUIContent ShadeColor_StepText =
new GUIContent("Step");
public static GUIContent Shades_1st2nd_FeatherText =
new GUIContent("Feather");
public static GUIContent Set_SystemShadowsToBaseText =
new GUIContent("Enable System Shadow");
public static GUIContent Tweak_SystemShadowsLevelText =
new GUIContent("Tweak SystemShadowsLevel");
//HighColor
public static GUIContent HighColorText =
new GUIContent("HighColor");
public static GUIContent HighColor_TexText =
new GUIContent("High Color");
public static GUIContent Is_LightColor_HighColorText =
new GUIContent("Use LightColor");
public static GUIContent Is_NormalMapToHighColorText =
new GUIContent("_Is_NormalMapToHighColor");
public static GUIContent HighColor_PowerText =
new GUIContent("Power");
public static GUIContent Is_SpecularToHighColorText =
new GUIContent("Specular mode");
public static GUIContent Is_BlendAddToHiColorText =
new GUIContent("Draw Blend Add");
public static GUIContent Is_UseTweakHighColorOnShadowText =
new GUIContent("Draw on shadow");
public static GUIContent TweakHighColorOnShadowText =
new GUIContent("_TweakHighColorOnShadow");
public static GUIContent Set_HighColorMaskText =
new GUIContent("Mask");
public static GUIContent Tweak_HighColorMaskLevelText =
new GUIContent("MaskLevel");
//RimLight
public static GUIContent RimLightText =
new GUIContent("Enable RimLight");
public static GUIContent RimLightColorText =
new GUIContent("Color");
public static GUIContent Is_LightColor_RimLightText =
new GUIContent("Use LightColor");
public static GUIContent Is_NormalMapToRimLightText =
new GUIContent("_Is_NormalMapToRimLight");
public static GUIContent RimLight_PowerText =
new GUIContent("Power");
public static GUIContent RimLight_InsideMaskText =
new GUIContent("Inside Mask");
public static GUIContent RimLight_FeatherOffText =
new GUIContent("Feather Off");
public static GUIContent LightDirection_MaskOnText =
new GUIContent("Light Direction Mask");
public static GUIContent Tweak_LightDirection_MaskLevelText =
new GUIContent("_Tweak_LightDirection_MaskLevel");
//Ap RimLight
public static GUIContent Add_Antipodean_RimLightText =
new GUIContent("Enable Ap RimLight");
public static GUIContent Ap_RimLightColoTextr =
new GUIContent("Color");
public static GUIContent Is_LightColor_Ap_RimLightText =
new GUIContent("Use LightColor");
public static GUIContent Ap_RimLight_PowerText =
new GUIContent("Power");
public static GUIContent Ap_RimLight_FeatherOffText =
new GUIContent("Feather Off");
public static GUIContent Set_RimLightMaskText =
new GUIContent("Mask");
public static GUIContent Tweak_RimLightMaskLevelText =
new GUIContent("Mask Level");
//MatCap
public static GUIContent MatCapText =
new GUIContent("Enable MatCap");
public static GUIContent MatCap_SamplerText =
new GUIContent("Sampler");
public static GUIContent MatCapColorText =
new GUIContent("_MatCapColor");
public static GUIContent Is_LightColor_MatCapText=
new GUIContent("Use LightColor");
public static GUIContent Is_BlendAddToMatCapText =
new GUIContent("Blend Add");
public static GUIContent Tweak_MatCapUVText =
new GUIContent("Tweak UV");
public static GUIContent Rotate_MatCapUVText =
new GUIContent("Rotate UV");
public static GUIContent Is_NormalMapForMatCapText =
new GUIContent("_Is_NormalMapForMatCap");
public static GUIContent NormalMapForMatCapText =
new GUIContent("Normal");
public static GUIContent Rotate_NormalMapForMatCapUVText =
new GUIContent("Rotate UV");
public static GUIContent Is_UseTweakMatCapOnShadowText =
new GUIContent("Draw on shadow");
public static GUIContent TweakMatCapOnShadowText =
new GUIContent("_TweakMatCapOnShadow");
//Emissive
public static GUIContent Emissive_TexText =
new GUIContent("Emissive Tex");
public static GUIContent Emissive_ColorText =
new GUIContent("_Emissive_Color");
//Outline
public static GUIContent OUTLINEText =
new GUIContent("Mode");
public static GUIContent Outline_WidthText =
new GUIContent("Width");
public static GUIContent Farthest_DistanceText =
new GUIContent("Far");
public static GUIContent Nearest_DistanceText =
new GUIContent("Near");
public static GUIContent Outline_SamplerText =
new GUIContent("Edge");
public static GUIContent Outline_ColorText =
new GUIContent("Color");
public static GUIContent Is_BlendBaseColoTextr =
new GUIContent("Blend BaseColor");
//v.2.0.4
public static GUIContent Is_OutlineTexText =
new GUIContent("_Is_OutlineTex");
public static GUIContent OutlineTexText =
new GUIContent("Color");
//Offset parameter
public static GUIContent Offset_ZText =
new GUIContent("Offset Z");
public static GUIContent GI_IntensityText =
new GUIContent("Use Global Illumination");
//
public static string line = "----------------------------------------------";
public static string baseMap = "BaseMap";
public static string firstShadowMap = "1st Shadow";
public static string secondShadowMap = "2nd Shadow";
public static string systemShadow = "System Shadow";
public static string highColor = "High Color";
public static string rimLight = "RimLight";
public static string apRimLight = "AP(Antipoden) Rim Light";
public static string matCap = "MatCap";
public static string outLine = "OutLine";
public static string advancedText = "Advanced Options";
}
//
MaterialProperty _CullMode = null;
//Surface
MaterialProperty _BaseMap = null;
MaterialProperty _BaseColor = null;
MaterialProperty LightColor = null;
MaterialProperty _NormalMap = null;
MaterialProperty _Is_NormalMapToBase = null;
//1st Shadow
MaterialProperty _1st_ShadeMap = null;
MaterialProperty _1st_ShadeColor = null;
MaterialProperty _Set_1st_ShadePosition = null;
MaterialProperty _Is_LightColor_1st_Shade = null;
MaterialProperty _BaseColor_Step = null;
MaterialProperty _BaseShades_Feather = null;
//2nd Shadow
MaterialProperty _2nd_ShadeMap = null;
MaterialProperty _2nd_ShadeColor = null;
MaterialProperty _Set_2nd_ShadePosition = null;
MaterialProperty _Is_LightColor_2nd_Shade = null;
MaterialProperty _ShadeColor_Step = null;
MaterialProperty _1st2nd_Shades_Feather = null;
//system shader
MaterialProperty _Set_SystemShadowsToBase = null;
MaterialProperty _Tweak_SystemShadowsLevel = null;
//HighColor
MaterialProperty _HighColor = null;
MaterialProperty _HighColor_Tex = null;
MaterialProperty _Is_LightColor_HighColor = null;
MaterialProperty _Is_NormalMapToHighColor = null;
MaterialProperty _HighColor_Power = null;
MaterialProperty _Is_SpecularToHighColor = null;
MaterialProperty _Is_BlendAddToHiColor = null;
MaterialProperty _Is_UseTweakHighColorOnShadow = null;
MaterialProperty _TweakHighColorOnShadow = null;
MaterialProperty _Set_HighColorMask = null;
MaterialProperty _Tweak_HighColorMaskLevel = null;
//RimLight
MaterialProperty _RimLight = null;
MaterialProperty _RimLightColor = null;
MaterialProperty _Is_LightColor_RimLight = null;
MaterialProperty _Is_NormalMapToRimLight = null;
MaterialProperty _RimLight_Power = null;
MaterialProperty _RimLight_InsideMask = null;
MaterialProperty _RimLight_FeatherOff = null;
MaterialProperty _LightDirection_MaskOn = null;
MaterialProperty _Tweak_LightDirection_MaskLevel = null;
//Ap RimLight
MaterialProperty _Add_Antipodean_RimLight = null;
MaterialProperty _Ap_RimLightColor = null;
MaterialProperty _Is_LightColor_Ap_RimLight = null;
MaterialProperty _Ap_RimLight_Power = null;
MaterialProperty _Ap_RimLight_FeatherOff = null;
MaterialProperty _Set_RimLightMask = null;
MaterialProperty _Tweak_RimLightMaskLevel = null;
//MatCap
MaterialProperty _MatCap = null;
MaterialProperty _MatCap_Sampler = null;
MaterialProperty _MatCapColor = null;
MaterialProperty _Is_LightColor_MatCap = null;
MaterialProperty _Is_BlendAddToMatCap = null;
MaterialProperty _Tweak_MatCapUV = null;
MaterialProperty _Rotate_MatCapUV = null;
MaterialProperty _Is_NormalMapForMatCap = null;
MaterialProperty _NormalMapForMatCap = null;
MaterialProperty _Rotate_NormalMapForMatCapUV = null;
MaterialProperty _Is_UseTweakMatCapOnShadow = null;
MaterialProperty _TweakMatCapOnShadow = null;
//Emissive
MaterialProperty _Emissive_Tex = null;
MaterialProperty _Emissive_Color = null;
//Outline
MaterialProperty _OUTLINE = null;
MaterialProperty _Outline_Width = null;
MaterialProperty _Farthest_Distance = null;
MaterialProperty _Nearest_Distance = null;
MaterialProperty _Outline_Sampler = null;
MaterialProperty _Outline_Color = null;
MaterialProperty _Is_BlendBaseColor = null;
//v.2.0.4
MaterialProperty _Is_OutlineTex = null;
MaterialProperty _OutlineTex = null;
//Offset parameter
MaterialProperty _Offset_Z = null;
MaterialProperty _GI_Intensity = null;
MaterialEditor m_MaterialEditor;
bool m_FirstTimeApply = true;
public void FindProperties(MaterialProperty[] props)
{
//
_CullMode = FindProperty("_CullMode", props);
//Surface
_BaseMap = FindProperty("_BaseMap", props);
_BaseColor = FindProperty("_BaseColor", props);
LightColor = FindProperty("_Is_LightColor_Base", props);
_NormalMap = FindProperty("_NormalMap", props);
_Is_NormalMapToBase = FindProperty("_Is_NormalMapToBase", props);
//1st Shadow
_1st_ShadeMap = FindProperty("_1st_ShadeMap", props);
_1st_ShadeColor = FindProperty("_1st_ShadeColor", props);
_Is_LightColor_1st_Shade = FindProperty("_Is_LightColor_1st_Shade", props);
_BaseColor_Step = FindProperty("_BaseColor_Step", props);
_BaseShades_Feather = FindProperty("_BaseShade_Feather", props);
_Set_1st_ShadePosition = FindProperty("_Set_1st_ShadePosition", props);
//2nd Shadow
_2nd_ShadeMap = FindProperty("_2nd_ShadeMap", props);
_2nd_ShadeColor = FindProperty("_2nd_ShadeColor", props);
_Is_LightColor_2nd_Shade = FindProperty("_Is_LightColor_2nd_Shade", props);
_ShadeColor_Step = FindProperty("_ShadeColor_Step", props);
_1st2nd_Shades_Feather = FindProperty("_1st2nd_Shades_Feather", props);
_Set_2nd_ShadePosition = FindProperty("_Set_2nd_ShadePosition", props);
//system shadow
_Set_SystemShadowsToBase = FindProperty("_Set_SystemShadowsToBase", props);
_Tweak_SystemShadowsLevel = FindProperty("_Tweak_SystemShadowsLevel", props);
//HighColor
_HighColor = FindProperty("_HighColor", props);
_HighColor_Tex = FindProperty("_HighColor_Tex", props);
_Is_LightColor_HighColor = FindProperty("_Is_LightColor_HighColor", props);
_Is_NormalMapToHighColor = FindProperty("_Is_NormalMapToHighColor", props);
_HighColor_Power = FindProperty("_HighColor_Power", props);
_Is_SpecularToHighColor = FindProperty("_Is_SpecularToHighColor", props);
_Is_BlendAddToHiColor = FindProperty("_Is_BlendAddToHiColor", props);
_Is_UseTweakHighColorOnShadow = FindProperty("_Is_UseTweakHighColorOnShadow", props);
_TweakHighColorOnShadow = FindProperty("_TweakHighColorOnShadow", props);
_Set_HighColorMask = FindProperty("_Set_HighColorMask", props);
_Tweak_HighColorMaskLevel = FindProperty("_Tweak_HighColorMaskLevel", props);
//RimLight
_RimLight = FindProperty("_RimLight", props);
_RimLightColor = FindProperty("_RimLightColor", props);
_Is_LightColor_RimLight = FindProperty("_Is_LightColor_RimLight", props);
_Is_NormalMapToRimLight = FindProperty("_Is_NormalMapToRimLight", props);
_RimLight_Power = FindProperty("_RimLight_Power", props);
_RimLight_InsideMask = FindProperty("_RimLight_InsideMask", props);
_RimLight_FeatherOff = FindProperty("_RimLight_FeatherOff", props);
_LightDirection_MaskOn = FindProperty("_LightDirection_MaskOn", props);
_Tweak_LightDirection_MaskLevel = FindProperty("_Tweak_LightDirection_MaskLevel", props);
//Ap RimLight
_Add_Antipodean_RimLight = FindProperty("_Add_Antipodean_RimLight", props);
_Ap_RimLightColor = FindProperty("_Ap_RimLightColor", props);
_Is_LightColor_Ap_RimLight = FindProperty("_Is_LightColor_Ap_RimLight", props);
_Ap_RimLight_Power = FindProperty("_Ap_RimLight_Power", props);
_Ap_RimLight_FeatherOff = FindProperty("_Ap_RimLight_FeatherOff", props);
_Set_RimLightMask = FindProperty("_Set_RimLightMask", props);
_Tweak_RimLightMaskLevel = FindProperty("_Tweak_RimLightMaskLevel", props);
//MatCap
_MatCap = FindProperty("_MatCap", props);
_MatCap_Sampler = FindProperty("_MatCap_Sampler", props);
_MatCapColor = FindProperty("_MatCapColor", props);
_Is_LightColor_MatCap = FindProperty("_Is_LightColor_MatCap", props);
_Is_BlendAddToMatCap = FindProperty("_Is_BlendAddToMatCap", props);
_Tweak_MatCapUV = FindProperty("_Tweak_MatCapUV", props);
_Rotate_MatCapUV = FindProperty("_Rotate_MatCapUV", props);
_Is_NormalMapForMatCap = FindProperty("_Is_NormalMapForMatCap", props);
_NormalMapForMatCap = FindProperty("_NormalMapForMatCap", props);
_Rotate_NormalMapForMatCapUV = FindProperty("_Rotate_NormalMapForMatCapUV", props);
_Is_UseTweakMatCapOnShadow = FindProperty("_Is_UseTweakMatCapOnShadow", props);
_TweakMatCapOnShadow = FindProperty("_TweakMatCapOnShadow", props);
//Emissive
_Emissive_Tex = FindProperty("_Emissive_Tex", props);
_Emissive_Color = FindProperty("_Emissive_Color", props);
//Outline
_OUTLINE = FindProperty("_OUTLINE", props);
_Outline_Width = FindProperty("_Outline_Width", props);
_Farthest_Distance = FindProperty("_Farthest_Distance", props);
_Nearest_Distance = FindProperty("_Nearest_Distance", props);
_Outline_Sampler = FindProperty("_Outline_Sampler", props);
_Outline_Color = FindProperty("_Outline_Color", props);
_Is_BlendBaseColor = FindProperty("_Is_BlendBaseColor", props);
//v.2.0.4
_Is_OutlineTex = FindProperty("_Is_OutlineTex", props);
_OutlineTex = FindProperty("_OutlineTex", props);
//Offset parameter
_Offset_Z = FindProperty("_Offset_Z", props);
_GI_Intensity = FindProperty("_GI_Intensity", props);
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
FindProperties(props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
m_MaterialEditor = materialEditor;
Material material = materialEditor.target as Material;
// Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching some existing
// material to a standard shader.
// Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
if (m_FirstTimeApply)
{
m_FirstTimeApply = false;
}
ShaderPropertiesGUI(material);
}
static bool IsShowBaseMap = true;
static bool IsShow1stShadow = true;
static bool IsShow2ndShadow = true;
static bool IsShowHighColor = true;
static bool IsShowRimLight = true;
static bool IsShowApRimLight = true;
static bool IsShowMatCap = true;
static bool IsShowOutline = true;
static bool IsShowAdvance = true;
public void ShaderPropertiesGUI(Material material)
{
// Use default labelWidth
EditorGUIUtility.labelWidth = 0f;
// Detect any changes to the material
EditorGUI.BeginChangeCheck();
{
m_MaterialEditor.ShaderProperty(
_CullMode , Styles.CullModeText.text);
//*************************************************************
//Base
//*************************************************************
IsShowBaseMap = EditorGUILayout.Foldout (IsShowBaseMap, "BaseMap");
if (IsShowBaseMap) {
m_MaterialEditor.TexturePropertyTwoLines(
Styles.BaseMapText,
_BaseMap,
_BaseColor,
Styles.LightColor,
LightColor);
EditorGUI.indentLevel += 3;
//Enable System Shadow
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.ShaderProperty(
_Set_SystemShadowsToBase,
Styles.Set_SystemShadowsToBaseText.text);
//有効の時のみ表示
if (_Set_SystemShadowsToBase.floatValue == 1.0f)
{
m_MaterialEditor.RangeProperty(
_Tweak_SystemShadowsLevel, "");
}
}
EditorGUI.indentLevel -= 3;
//normal
m_MaterialEditor.TexturePropertySingleLine(
Styles.NormalMap,
_NormalMap);
if (_NormalMap.textureValue != null)
{
_Is_NormalMapToBase.floatValue = 1.0f;
_Is_NormalMapToHighColor.floatValue = 1.0f;
_Is_NormalMapToRimLight.floatValue = 1.0f;
}
else
{
_Is_NormalMapToBase.floatValue = 0.0f;
_Is_NormalMapToHighColor.floatValue = 0.0f;
_Is_NormalMapToRimLight.floatValue = 0.0f;
}
EditorGUILayout.Space();
}
//*************************************************************
//1st Shadow
//*************************************************************
//項目開閉
IsShow1stShadow = EditorGUILayout.Foldout (
IsShow1stShadow, "1st Shadow");
if (IsShow1stShadow) {
m_MaterialEditor.TexturePropertySingleLine(
Styles.ShadeMap_1st_Text,
_1st_ShadeMap, _1st_ShadeColor,
_BaseColor_Step);
EditorGUI.indentLevel += 3;
m_MaterialEditor.ShaderProperty(
_BaseShades_Feather,
Styles.BaseShade_FeatherText.text);
//Use Light Color
m_MaterialEditor.ShaderProperty(
_Is_LightColor_1st_Shade,
Styles.Is_LightColor_1st_ShadeText.text);
EditorGUI.indentLevel -= 3;
m_MaterialEditor.TexturePropertySingleLine(
Styles.Set_1st_ShadePositionText,
_Set_1st_ShadePosition);
EditorGUILayout.Space();
}
//*************************************************************
//2nd Shadow
//*************************************************************
//項目開閉
IsShow2ndShadow = EditorGUILayout.Foldout (
IsShow2ndShadow, "2nd Shadow");
if (IsShow2ndShadow) {
m_MaterialEditor.TexturePropertySingleLine(
Styles.ShadeMap_2nd_Text,
_2nd_ShadeMap, _2nd_ShadeColor,
_ShadeColor_Step);
EditorGUI.indentLevel += 3;
m_MaterialEditor.ShaderProperty(
_1st2nd_Shades_Feather,
Styles.Shades_1st2nd_FeatherText.text);
//Use Light Color
m_MaterialEditor.ShaderProperty(
_Is_LightColor_2nd_Shade,
Styles.Is_LightColor_2nd_ShadeText.text);
EditorGUI.indentLevel -= 3;
m_MaterialEditor.TexturePropertySingleLine(
Styles.Set_2nd_ShadePositionText,
_Set_2nd_ShadePosition);
EditorGUILayout.Space();
}
//*************************************************************
//High Color
//*************************************************************
//項目開閉
IsShowHighColor = EditorGUILayout.Foldout (
IsShowHighColor, "High Color");
if (IsShowHighColor) {
m_MaterialEditor.TexturePropertySingleLine(
Styles.HighColor_TexText,
_HighColor_Tex,
_HighColor,
_HighColor_Power);
EditorGUI.indentLevel+=3;
m_MaterialEditor.ShaderProperty(
_Is_SpecularToHighColor ,
Styles.Is_SpecularToHighColorText.text);
m_MaterialEditor.ShaderProperty(
_Is_BlendAddToHiColor ,
Styles.Is_BlendAddToHiColorText.text);
//Draw on shadow
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.ShaderProperty(
_Is_UseTweakHighColorOnShadow ,
Styles.Is_UseTweakHighColorOnShadowText.text);
//有効の時のみ表示
if (_Is_UseTweakHighColorOnShadow.floatValue == 1.0f)
{
m_MaterialEditor.ShaderProperty(
_TweakHighColorOnShadow ,
"");
}
}
//Use Light Color
m_MaterialEditor.ShaderProperty(
_Is_LightColor_HighColor ,
Styles.Is_LightColor_HighColorText.text);
EditorGUI.indentLevel-=3;
//Mask
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.TexturePropertySingleLine(
Styles.Set_HighColorMaskText,
_Set_HighColorMask);
//有効の時のみ表示
if (_Set_HighColorMask.textureValue != null)
{
m_MaterialEditor.ShaderProperty(
_Tweak_HighColorMaskLevel ,
"");
}
}
EditorGUILayout.Space();
}
//*************************************************************
//RimLight
//*************************************************************
//項目開閉
IsShowRimLight = EditorGUILayout.Foldout (
IsShowRimLight, "Rim Light");
if (IsShowRimLight) {
m_MaterialEditor.ShaderProperty(
_RimLight , Styles.RimLightText.text);
//有効の時のみ表示
if (_RimLight.floatValue == 1.0f)
{
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.ShaderProperty(
_RimLightColor ,
Styles.RimLightColorText.text);
m_MaterialEditor.ShaderProperty(
_RimLight_Power ,
"");
}
EditorGUI.indentLevel+=3;
//feather off
m_MaterialEditor.ShaderProperty(
_RimLight_FeatherOff ,
Styles.RimLight_FeatherOffText.text);
//inside mask
m_MaterialEditor.ShaderProperty(
_RimLight_InsideMask ,
Styles.RimLight_InsideMaskText.text);
//Light Direction Mask
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.ShaderProperty(
_LightDirection_MaskOn ,
Styles.LightDirection_MaskOnText.text);
//有効の時のみ表示
if (_LightDirection_MaskOn.floatValue == 1.0f)
{
m_MaterialEditor.ShaderProperty(
_Tweak_LightDirection_MaskLevel ,
"");
}
}
//Use Light Color
m_MaterialEditor.ShaderProperty(
_Is_LightColor_RimLight ,
Styles.Is_LightColor_RimLightText.text);
EditorGUI.indentLevel-=3;
//Mask
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.TexturePropertySingleLine(
Styles.Set_RimLightMaskText,
_Set_RimLightMask);
//有効の時のみ表示
if (_Set_RimLightMask.textureValue != null)
{
m_MaterialEditor.ShaderProperty(
_Tweak_RimLightMaskLevel ,
"");
}
}
}
EditorGUILayout.Space();
}
//*************************************************************
//ApRimLight
//*************************************************************
//項目開閉
IsShowApRimLight = EditorGUILayout.Foldout (
IsShowApRimLight, "AP(Antipoden)Rim Light");
if (IsShowApRimLight) {
m_MaterialEditor.ShaderProperty(
_Add_Antipodean_RimLight ,
Styles.Add_Antipodean_RimLightText.text);
//有効の時のみ表示
if (_Add_Antipodean_RimLight.floatValue == 1.0f)
{
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.ShaderProperty(
_Ap_RimLightColor ,
Styles.Ap_RimLightColoTextr.text);
m_MaterialEditor.ShaderProperty(
_Ap_RimLight_Power ,
"");
}
EditorGUI.indentLevel+=3;
m_MaterialEditor.ShaderProperty(
_Ap_RimLight_FeatherOff ,
Styles.Ap_RimLight_FeatherOffText.text);
m_MaterialEditor.ShaderProperty(
_Is_LightColor_Ap_RimLight ,
Styles.Is_LightColor_Ap_RimLightText.text);
EditorGUI.indentLevel-=3;
}
EditorGUILayout.Space();
}
//*************************************************************
//MatCap
//*************************************************************
//項目開閉
IsShowMatCap = EditorGUILayout.Foldout (
IsShowMatCap, "MatCap");
if (IsShowMatCap) {
m_MaterialEditor.ShaderProperty(
_MatCap , Styles.MatCapText.text);
//有効の時のみ表示
if (_MatCap.floatValue == 1.0f)
{
m_MaterialEditor.TexturePropertySingleLine(
Styles.MatCap_SamplerText,
_MatCap_Sampler,
_MatCapColor);
EditorGUI.indentLevel+=3;
m_MaterialEditor.ShaderProperty(
_Is_BlendAddToMatCap ,
Styles.Is_BlendAddToMatCapText.text);
m_MaterialEditor.ShaderProperty(
_Tweak_MatCapUV ,
Styles.Tweak_MatCapUVText.text);
m_MaterialEditor.ShaderProperty(
_Rotate_MatCapUV ,
Styles.Rotate_MatCapUVText.text);
//Draw on shadow
using (var horizontalScope = new GUILayout.HorizontalScope())
{
m_MaterialEditor.ShaderProperty(
_Is_UseTweakMatCapOnShadow ,
Styles.Is_UseTweakMatCapOnShadowText.text);
//有効の時のみ表示
if (_Is_UseTweakMatCapOnShadow.floatValue == 1.0f)
{
m_MaterialEditor.ShaderProperty(
_TweakMatCapOnShadow ,
"");
}
}
//Use Light Color
m_MaterialEditor.ShaderProperty(
_Is_LightColor_MatCap ,
Styles.Is_LightColor_MatCapText.text);
EditorGUI.indentLevel-=3;
//normal
m_MaterialEditor.TexturePropertySingleLine(
Styles.NormalMapForMatCapText,
_NormalMapForMatCap);
if (_NormalMapForMatCap.textureValue != null)
{
_Is_NormalMapForMatCap.floatValue = 1.0f;
EditorGUI.indentLevel+=3;
//Rotate UV
m_MaterialEditor.ShaderProperty(
_Rotate_NormalMapForMatCapUV ,
Styles.Rotate_NormalMapForMatCapUVText.text);
EditorGUI.indentLevel-=3;
}else
{
_Is_NormalMapForMatCap.floatValue = 0.0f;
}
}
EditorGUILayout.Space();
}
//*************************************************************
//Outline
//*************************************************************
//項目開閉
IsShowOutline = EditorGUILayout.Foldout (
IsShowOutline, "Outline");
if (IsShowOutline) {
//mode
m_MaterialEditor.ShaderProperty(
_OUTLINE , Styles.OUTLINEText.text);
//color
m_MaterialEditor.TexturePropertySingleLine(
Styles.OutlineTexText,
_OutlineTex,
_Outline_Color);
if (_OutlineTex.textureValue != null)
{
_Is_OutlineTex.floatValue = 1.0f;
}else
{
_Is_OutlineTex.floatValue = 0.0f;
}
EditorGUI.indentLevel+=3;
m_MaterialEditor.ShaderProperty(
_Outline_Width ,
Styles.Outline_WidthText.text);
m_MaterialEditor.ShaderProperty(
_Farthest_Distance ,
Styles.Farthest_DistanceText.text);
m_MaterialEditor.ShaderProperty(
_Nearest_Distance ,
Styles.Nearest_DistanceText.text);
m_MaterialEditor.ShaderProperty(
_Is_BlendBaseColor ,
Styles.Is_BlendBaseColoTextr.text);
m_MaterialEditor.ShaderProperty(
_Offset_Z , Styles.Offset_ZText.text);
EditorGUI.indentLevel-=3;
//Edge
m_MaterialEditor.TexturePropertySingleLine(
Styles.Outline_SamplerText,
_Outline_Sampler);
EditorGUILayout.Space();
}
//*************************************************************
//Advance
//*************************************************************
//項目開閉
IsShowAdvance = EditorGUILayout.Foldout (
IsShowAdvance, "Advance");
if (IsShowAdvance) {
m_MaterialEditor.TexturePropertySingleLine(
Styles.Emissive_TexText,
_Emissive_Tex,
_Emissive_Color);
m_MaterialEditor.ShaderProperty(
_GI_Intensity ,
Styles.GI_IntensityText.text);
}
}
EditorGUILayout.Space();
}
}
} // namespace UnityEditor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment