[Add] All in one shader
This commit is contained in:
+894
@@ -0,0 +1,894 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Linq;
|
||||
using AllIn1SpriteShader;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
public class AllIn12DRendererMaterialInspector : ShaderGUI
|
||||
{
|
||||
private Material targetMat;
|
||||
private BlendMode srcMode, dstMode;
|
||||
private CompareFunction zTestMode = CompareFunction.LessEqual;
|
||||
private CullMode cullMode;
|
||||
|
||||
private GUIStyle propertiesStyle, bigLabelStyle, smallLabelStyle, toggleButtonStyle;
|
||||
private const int bigFontSize = 16, smallFontSize = 11;
|
||||
private string[] oldKeyWords;
|
||||
private int effectCount = 1;
|
||||
private Material originalMaterialCopy;
|
||||
private MaterialEditor matEditor;
|
||||
private MaterialProperty[] matProperties;
|
||||
private uint[] materialDrawers = new uint[] { 1, 2, 4, 8 };
|
||||
bool[] currEnabledDrawers;
|
||||
private const uint advancedConfigDrawer = 0;
|
||||
private const uint colorFxShapeDrawer = 1;
|
||||
private const uint uvFxShapeDrawer = 2;
|
||||
private const uint lightingDrawer = 3;
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
matEditor = materialEditor;
|
||||
matProperties = properties;
|
||||
targetMat = materialEditor.target as Material;
|
||||
effectCount = 1;
|
||||
oldKeyWords = targetMat.shaderKeywords;
|
||||
propertiesStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
propertiesStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
bigLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
bigLabelStyle.fontSize = bigFontSize;
|
||||
smallLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
smallLabelStyle.fontSize = smallFontSize;
|
||||
toggleButtonStyle = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleCenter, richText = true };
|
||||
currEnabledDrawers = new bool[materialDrawers.Length];
|
||||
uint iniDrawers = (uint)ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue;
|
||||
for(int i = 0; i < materialDrawers.Length; i++) currEnabledDrawers[i] = (materialDrawers[i] & iniDrawers) > 0;
|
||||
|
||||
GUILayout.Label("General Properties", bigLabelStyle);
|
||||
DrawProperty(0);
|
||||
DrawProperty(177);
|
||||
DrawProperty(1);
|
||||
DrawProperty(2);
|
||||
|
||||
currEnabledDrawers[advancedConfigDrawer] = GUILayout.Toggle(currEnabledDrawers[advancedConfigDrawer], new GUIContent("<size=12>Show Advanced Configuration</size>"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[advancedConfigDrawer])
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
Blending();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
Culling();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ZTest();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ZWrite();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
Billboard("Bilboard active", "BILBOARD_ON");
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
SpriteAtlas("Sprite inside an atlas?", "ATLAS_ON");
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.EnableInstancingField();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.RenderQueueField();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("Lighting Properties", bigLabelStyle);
|
||||
currEnabledDrawers[lightingDrawer] = GUILayout.Toggle(currEnabledDrawers[lightingDrawer], new GUIContent("Show Lighting Properties"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[lightingDrawer])
|
||||
{
|
||||
for (int i = 172; i <= 175; i++) DrawProperty(i);
|
||||
DrawProperty(176, true);
|
||||
MaterialProperty glowLight = properties[176];
|
||||
if (glowLight.floatValue == 1) targetMat.EnableKeyword("GLOWLIGHT_ON");
|
||||
else targetMat.DisableKeyword("GLOWLIGHT_ON");
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("Color Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[colorFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[colorFxShapeDrawer], new GUIContent("Show Color Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[colorFxShapeDrawer])
|
||||
{
|
||||
Glow("Glow", "GLOW_ON");
|
||||
Fade("Fade", "FADE_ON");
|
||||
|
||||
Outline("Outline", "OUTBASE_ON");
|
||||
GenericEffect("Alpha Outline", "ALPHAOUTLINE_ON", 26, 30, true, "A more performant but less flexible outline");
|
||||
InnerOutline("Inner Outline", "INNEROUTLINE_ON", 66, 69);
|
||||
Gradient("Gradient & Radial Gradient", "GRADIENT_ON");
|
||||
GenericEffect("Color Swap", "COLORSWAP_ON", 36, 42, true, "You will need a mask texture (see Documentation)", new int[] { 154 });
|
||||
GenericEffect("Hue Shift", "HSV_ON", 43, 45);
|
||||
ColorChange("Change 1 Color", "CHANGECOLOR_ON");
|
||||
ColorRamp("Color Ramp", "COLORRAMP_ON");
|
||||
GenericEffect("Hit Effect", "HITEFFECT_ON", 46, 48);
|
||||
GenericEffect("Negative", "NEGATIVE_ON", 49, 49);
|
||||
GenericEffect("Pixelate", "PIXELATE_ON", 50, 50, true, "Looks bad with distorition effects");
|
||||
GreyScale("GreyScale", "GREYSCALE_ON");
|
||||
Posterize("Posterize", "POSTERIZE_ON");
|
||||
Blur("Blur", "BLUR_ON");
|
||||
GenericEffect("Motion Blur", "MOTIONBLUR_ON", 62, 63);
|
||||
GenericEffect("Ghost", "GHOST_ON", 64, 65, true, "This effect will not affect the outline", new int[] { 157 });
|
||||
GenericEffect("Hologram", "HOLOGRAM_ON", 73, 77, true, null, new int[] { 140, 158 });
|
||||
GenericEffect("Chromatic Aberration", "CHROMABERR_ON", 78, 79);
|
||||
GenericEffect("Glitch", "GLITCH_ON", 80, 80, true, null, new int[] { 139, 184 });
|
||||
GenericEffect("Flicker", "FLICKER_ON", 81, 83);
|
||||
GenericEffect("Shadow", "SHADOW_ON", 84, 87);
|
||||
GenericEffect("Shine", "SHINE_ON", 133, 138);
|
||||
GenericEffect("Contrast & Brightness", "CONTRAST_ON", 152, 153);
|
||||
Overlay("Overlay Texture", "OVERLAY_ON");
|
||||
GenericEffect("Alpha Cutoff", "ALPHACUTOFF_ON", 70, 70);
|
||||
GenericEffect("Alpha Round", "ALPHAROUND_ON", 144, 144);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("UV Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[uvFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[uvFxShapeDrawer], new GUIContent("Show Alpha Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[uvFxShapeDrawer])
|
||||
{
|
||||
GenericEffect("Hand Drawn", "DOODLE_ON", 88, 89);
|
||||
Grass("Grass Movement / Wind", "WIND_ON");
|
||||
GenericEffect("Wave", "WAVEUV_ON", 94, 98);
|
||||
GenericEffect("Round Wave", "ROUNDWAVEUV_ON", 127, 128);
|
||||
GenericEffect("Rect Size (Enable wireframe to see result)", "RECTSIZE_ON", 99, 99, true, "Only on single sprites spritesheets NOT supported");
|
||||
GenericEffect("Offset", "OFFSETUV_ON", 100, 101);
|
||||
GenericEffect("Clipping / Fill Amount", "CLIPPING_ON", 102, 105);
|
||||
GenericEffect("Radial Clipping / Radial Fill", "RADIALCLIPPING_ON", 164, 166);
|
||||
GenericEffect("Texture Scroll", "TEXTURESCROLL_ON", 106, 107, true, "Set Texture Wrap Mode to Repeat");
|
||||
GenericEffect("Zoom", "ZOOMUV_ON", 108, 108);
|
||||
GenericEffect("Distortion", "DISTORT_ON", 109, 112, true, null, new int[] { 182 });
|
||||
GenericEffect("Warp Distortion", "WARP_ON", 167, 169);
|
||||
GenericEffect("Twist", "TWISTUV_ON", 113, 116);
|
||||
GenericEffect("Rotate", "ROTATEUV_ON", 117, 117, true, "_Tip_ Use Clipping effect to avoid possible undesired parts");
|
||||
GenericEffect("Polar Coordinates (Tile texture for good results)", "POLARUV_ON", -1, -1);
|
||||
GenericEffect("Fish Eye", "FISHEYE_ON", 118, 118);
|
||||
GenericEffect("Pinch", "PINCH_ON", 119, 119);
|
||||
GenericEffect("Shake", "SHAKEUV_ON", 120, 122);
|
||||
}
|
||||
|
||||
SetAndSaveEnabledDrawers(iniDrawers);
|
||||
}
|
||||
|
||||
private void SetAndSaveEnabledDrawers(uint iniDrawers)
|
||||
{
|
||||
uint currDrawers = 0;
|
||||
for(int i = 0; i < currEnabledDrawers.Length; i++)
|
||||
{
|
||||
if(currEnabledDrawers[i]) currDrawers |= materialDrawers[i];
|
||||
}
|
||||
|
||||
if(iniDrawers != currDrawers) ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue = currDrawers;
|
||||
}
|
||||
|
||||
private void Blending()
|
||||
{
|
||||
MaterialProperty srcM = ShaderGUI.FindProperty("_MySrcMode", matProperties);
|
||||
MaterialProperty dstM = ShaderGUI.FindProperty("_MyDstMode", matProperties);
|
||||
if(srcM.floatValue == 0 && dstM.floatValue == 0)
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
}
|
||||
|
||||
GUILayout.Label("Look for 'ShaderLab: Blending' if you don't know what this is", smallLabelStyle);
|
||||
if(GUILayout.Button("Back To Default Blending"))
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
srcMode = (BlendMode)srcM.floatValue;
|
||||
dstMode = (BlendMode)dstM.floatValue;
|
||||
srcMode = (BlendMode)EditorGUILayout.EnumPopup("SrcMode", srcMode);
|
||||
dstMode = (BlendMode)EditorGUILayout.EnumPopup("DstMode", dstMode);
|
||||
srcM.floatValue = (float)(srcMode);
|
||||
dstM.floatValue = (float)(dstMode);
|
||||
|
||||
bool ini = oldKeyWords.Contains("PREMULTIPLYALPHA_ON");
|
||||
bool toggle = EditorGUILayout.Toggle("Premultiply Alpha?", ini);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle) targetMat.EnableKeyword("PREMULTIPLYALPHA_ON");
|
||||
else targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
private void Billboard(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = inspector;
|
||||
toggle = GUILayout.Toggle(toggle, effectNameLabel);
|
||||
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
GUILayout.Label("Don't use this feature on UI elements!", smallLabelStyle);
|
||||
DrawProperty(129, true);
|
||||
MaterialProperty billboardY = matProperties[129];
|
||||
if(billboardY.floatValue == 1) targetMat.EnableKeyword("BILBOARDY_ON");
|
||||
else targetMat.DisableKeyword("BILBOARDY_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
private void ZWrite()
|
||||
{
|
||||
MaterialProperty zWrite = ShaderGUI.FindProperty("_ZWrite", matProperties);
|
||||
bool toggle = zWrite.floatValue > 0.9f ? true : false;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
float tempValue = zWrite.floatValue;
|
||||
toggle = GUILayout.Toggle(toggle, new GUIContent("Enable Z Write"));
|
||||
if(toggle) zWrite.floatValue = 1.0f;
|
||||
else zWrite.floatValue = 0.0f;
|
||||
if(tempValue != zWrite.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void ZTest()
|
||||
{
|
||||
MaterialProperty zTestM = ShaderGUI.FindProperty("_ZTestMode", matProperties);
|
||||
float tempValue = zTestM.floatValue;
|
||||
zTestMode = (UnityEngine.Rendering.CompareFunction)zTestM.floatValue;
|
||||
zTestMode = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("Z TestMode", zTestMode);
|
||||
zTestM.floatValue = (float)(zTestMode);
|
||||
if(tempValue != zTestM.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
|
||||
private void Culling()
|
||||
{
|
||||
MaterialProperty cullO = ShaderGUI.FindProperty("_CullingOption", matProperties);;
|
||||
float tempValue = cullO.floatValue;
|
||||
cullMode = (UnityEngine.Rendering.CullMode)cullO.floatValue;
|
||||
cullMode = (UnityEngine.Rendering.CullMode)EditorGUILayout.EnumPopup("Culling Mode", cullMode);
|
||||
cullO.floatValue = (float)(cullMode);
|
||||
if(tempValue != cullO.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
|
||||
private void SpriteAtlas(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
toggle = GUILayout.Toggle(toggle, inspector);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("Make sure SpriteAtlasUV component is added \n " +
|
||||
"*Check documentation if unsure what this does or how it works", smallLabelStyle);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
private void Fade(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + ".Fade";
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if (ini != toggle) Save();
|
||||
if (toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(7);
|
||||
DrawProperty(178);
|
||||
|
||||
DrawProperty(8);
|
||||
DrawProperty(9);
|
||||
DrawProperty(10);
|
||||
DrawProperty(11);
|
||||
|
||||
DrawProperty(12);
|
||||
DrawProperty(179);
|
||||
|
||||
DrawProperty(13);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else
|
||||
{
|
||||
targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Outline(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + ".Outline";
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("OUTBASE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(14);
|
||||
DrawProperty(15);
|
||||
DrawProperty(16);
|
||||
DrawEffectSubKeywordToggle("Outline High Resolution?", "OUTBASE8DIR_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlinePixelPerf = DrawEffectSubKeywordToggle("Outline is Pixel Perfect?", "OUTBASEPIXELPERF_ON");
|
||||
if(outlinePixelPerf) DrawProperty(18);
|
||||
else DrawProperty(17);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineTexture = DrawEffectSubKeywordToggle("Outline uses texture?", "OUTTEX_ON");
|
||||
if(outlineTexture)
|
||||
{
|
||||
DrawProperty(19);
|
||||
DrawProperty(20);
|
||||
DrawProperty(21);
|
||||
DrawProperty(180);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineDistort = DrawEffectSubKeywordToggle("Outline uses distortion?", "OUTDIST_ON");
|
||||
if(outlineDistort)
|
||||
{
|
||||
DrawProperty(22);
|
||||
DrawProperty(23);
|
||||
DrawProperty(24);
|
||||
DrawProperty(25);
|
||||
DrawProperty(181);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
DrawEffectSubKeywordToggle("Only render outline?", "ONLYOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("OUTBASE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GenericEffect(string inspector, string keyword, int first, int last, bool effectCounter = true, string preMessage = null, int[] extraProperties = null, bool boldToggleLetters = true)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
if(effectCounter)
|
||||
{
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
effectCount++;
|
||||
}
|
||||
else effectNameLabel.text = inspector;
|
||||
if(boldToggleLetters) toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
else toggle = GUILayout.Toggle(toggle, effectNameLabel);
|
||||
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
if(preMessage != null) GUILayout.Label(preMessage, smallLabelStyle);
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
if(extraProperties != null)
|
||||
foreach(int i in extraProperties)
|
||||
DrawProperty(i);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
if(boldToggleLetters) EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Glow(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GLOW_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useGlowTex = DrawEffectSubKeywordToggle("Use Glow Texture?", "GLOWTEX_ON");
|
||||
if(useGlowTex) DrawProperty(6);
|
||||
|
||||
DrawProperty(3);
|
||||
DrawProperty(4);
|
||||
DrawProperty(5, true);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GLOW_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorRamp(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("COLORRAMP_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useEditableGradient = false;
|
||||
if(AssetDatabase.Contains(targetMat))
|
||||
{
|
||||
useEditableGradient = oldKeyWords.Contains("GRADIENTCOLORRAMP_ON");
|
||||
bool gradientTex = useEditableGradient;
|
||||
gradientTex = GUILayout.Toggle(gradientTex, new GUIContent("Use Editable Gradient?"));
|
||||
if(useEditableGradient != gradientTex)
|
||||
{
|
||||
Save();
|
||||
if(gradientTex)
|
||||
{
|
||||
useEditableGradient = true;
|
||||
targetMat.EnableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
|
||||
if(useEditableGradient) matEditor.ShaderProperty(matProperties[159], matProperties[159].displayName);
|
||||
}
|
||||
else GUILayout.Label("*Save to folder to allow for dynamic Gradient property", smallLabelStyle);
|
||||
|
||||
if(!useEditableGradient) DrawProperty(51);
|
||||
|
||||
DrawProperty(52);
|
||||
DrawProperty(53, true);
|
||||
MaterialProperty colorRampOut = matProperties[53];
|
||||
if(colorRampOut.floatValue == 1) targetMat.EnableKeyword("COLORRAMPOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("COLORRAMPOUTLINE_ON");
|
||||
DrawProperty(155);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("COLORRAMP_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorChange(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = 123; i < 127; i++) DrawProperty(i);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR2_ON");
|
||||
bool toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 2", ini);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR2_ON");
|
||||
for(int i = 146; i < 149; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR2_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR3_ON");
|
||||
toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 3", toggle2);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR3_ON");
|
||||
for(int i = 149; i < 152; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR3_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GreyScale(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GREYSCALE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(54);
|
||||
DrawProperty(56);
|
||||
DrawProperty(55, true);
|
||||
MaterialProperty greyScaleOut = matProperties[55];
|
||||
if(greyScaleOut.floatValue == 1) targetMat.EnableKeyword("GREYSCALEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("GREYSCALEOUTLINE_ON");
|
||||
DrawProperty(156);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GREYSCALE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Posterize(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("POSTERIZE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(57);
|
||||
DrawProperty(58);
|
||||
DrawProperty(59, true);
|
||||
MaterialProperty posterizeOut = matProperties[59];
|
||||
if(posterizeOut.floatValue == 1) targetMat.EnableKeyword("POSTERIZEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("POSTERIZEOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("POSTERIZE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Blur(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("BLUR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("This effect will not affect the outline", smallLabelStyle);
|
||||
DrawProperty(60);
|
||||
DrawProperty(61, true);
|
||||
MaterialProperty blurIsHd = matProperties[61];
|
||||
if(blurIsHd.floatValue == 1) targetMat.EnableKeyword("BLURISHD_ON");
|
||||
else targetMat.DisableKeyword("BLURISHD_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("BLUR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Grass(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("WIND_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(90);
|
||||
DrawProperty(91);
|
||||
DrawProperty(145);
|
||||
DrawProperty(92);
|
||||
DrawProperty(93, true);
|
||||
MaterialProperty grassManual = matProperties[92];
|
||||
if(grassManual.floatValue == 1) targetMat.EnableKeyword("MANUALWIND_ON");
|
||||
else targetMat.DisableKeyword("MANUALWIND_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("WIND_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void InnerOutline(string inspector, string keyword, int first, int last)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawProperty(72, true);
|
||||
MaterialProperty onlyInOutline = matProperties[72];
|
||||
if(onlyInOutline.floatValue == 1) targetMat.EnableKeyword("ONLYINNEROUTLINE_ON");
|
||||
else targetMat.DisableKeyword("ONLYINNEROUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Gradient(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(143, true);
|
||||
MaterialProperty gradIsRadial = matProperties[143];
|
||||
if(gradIsRadial.floatValue == 1)
|
||||
{
|
||||
targetMat.EnableKeyword("RADIALGRADIENT_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
DrawProperty(34);
|
||||
DrawProperty(141);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetMat.DisableKeyword("RADIALGRADIENT_ON");
|
||||
bool simpleGradient = oldKeyWords.Contains("GRADIENT2COL_ON");
|
||||
bool simpleGradToggle = EditorGUILayout.Toggle("2 Color Gradient?", simpleGradient);
|
||||
if(simpleGradient && !simpleGradToggle) targetMat.DisableKeyword("GRADIENT2COL_ON");
|
||||
else if(!simpleGradient && simpleGradToggle) targetMat.EnableKeyword("GRADIENT2COL_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
if(!simpleGradToggle) DrawProperty(33);
|
||||
DrawProperty(34);
|
||||
if(!simpleGradToggle) DrawProperty(35);
|
||||
if(!simpleGradToggle) DrawProperty(141);
|
||||
DrawProperty(142);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Overlay(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool multModeOn = oldKeyWords.Contains("OVERLAYMULT_ON");
|
||||
bool isMultMode = multModeOn;
|
||||
isMultMode = GUILayout.Toggle(isMultMode, new GUIContent("Is overlay multiplicative?"));
|
||||
if(multModeOn != isMultMode)
|
||||
{
|
||||
Save();
|
||||
if(isMultMode)
|
||||
{
|
||||
multModeOn = true;
|
||||
targetMat.EnableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
|
||||
if(multModeOn) GUILayout.Label("Overlay is set to multiplicative mode", smallLabelStyle);
|
||||
else GUILayout.Label("Overlay is set to additive mode", smallLabelStyle);
|
||||
|
||||
DrawProperty(160);
|
||||
DrawProperty(183);
|
||||
DrawProperty(161);
|
||||
DrawProperty(162);
|
||||
DrawProperty(163);
|
||||
|
||||
|
||||
for(int i = 170; i <= 171; i++) DrawProperty(i);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void DrawProperty(int index, bool noReset = false)
|
||||
{
|
||||
MaterialProperty targetProperty = matProperties[index];
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = targetProperty.displayName;
|
||||
propertyLabel.tooltip = targetProperty.name + " (C#)";
|
||||
|
||||
matEditor.ShaderProperty(targetProperty, propertyLabel);
|
||||
|
||||
if(!noReset)
|
||||
{
|
||||
GUIContent resetButtonLabel = new GUIContent();
|
||||
resetButtonLabel.text = "R";
|
||||
resetButtonLabel.tooltip = "Resets to default value";
|
||||
if(GUILayout.Button(resetButtonLabel, GUILayout.Width(20))) ResetProperty(targetProperty);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void ResetProperty(MaterialProperty targetProperty)
|
||||
{
|
||||
AllIn1ShaderPropertyType propertyType = EditorUtils.GetShaderTypeByMaterialProperty(targetProperty);
|
||||
|
||||
if(originalMaterialCopy == null) originalMaterialCopy = new Material(targetMat.shader);
|
||||
if(propertyType == AllIn1ShaderPropertyType.Float || propertyType == AllIn1ShaderPropertyType.Range)
|
||||
{
|
||||
targetProperty.floatValue = originalMaterialCopy.GetFloat(targetProperty.name);
|
||||
}
|
||||
else if(propertyType == AllIn1ShaderPropertyType.Vector)
|
||||
{
|
||||
targetProperty.vectorValue = originalMaterialCopy.GetVector(targetProperty.name);
|
||||
}
|
||||
else if(propertyType == AllIn1ShaderPropertyType.Color)
|
||||
{
|
||||
targetProperty.colorValue = originalMaterialCopy.GetColor(targetProperty.name);
|
||||
}
|
||||
else if(propertyType == AllIn1ShaderPropertyType.Texture)
|
||||
{
|
||||
targetProperty.textureValue = originalMaterialCopy.GetTexture(targetProperty.name);
|
||||
}
|
||||
}
|
||||
|
||||
private bool DrawEffectSubKeywordToggle(string inspector, string keyword, bool setCustomConfigAfter = false)
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = inspector;
|
||||
propertyLabel.tooltip = keyword + " (C#)";
|
||||
|
||||
bool ini = oldKeyWords.Contains(keyword);
|
||||
bool toggle = ini;
|
||||
toggle = GUILayout.Toggle(toggle, propertyLabel);
|
||||
if(ini != toggle)
|
||||
{
|
||||
if(toggle) targetMat.EnableKeyword(keyword);
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
return toggle;
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
if(!Application.isPlaying) EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
EditorUtility.SetDirty(targetMat);
|
||||
}
|
||||
|
||||
private void DrawLine(Color color, int thickness = 2, int padding = 10)
|
||||
{
|
||||
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
|
||||
r.height = thickness;
|
||||
r.y += (padding / 2);
|
||||
r.x -= 2;
|
||||
r.width += 6;
|
||||
EditorGUI.DrawRect(r, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e063793833d64b7439fd1f34dc70b052
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn12DRendererMaterialInspector.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,26 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
public class AllIn1ShaderAssetPostProcessor : AssetPostprocessor
|
||||
{
|
||||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
|
||||
{
|
||||
bool needToRefreshConfig = false;
|
||||
for (int i = 0; i < importedAssets.Length; i++)
|
||||
{
|
||||
if (importedAssets[i].EndsWith(Constants.MAIN_ASSEMBLY_NAME))
|
||||
{
|
||||
needToRefreshConfig = needToRefreshConfig || true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needToRefreshConfig)
|
||||
{
|
||||
AllIn1ShaderImporter.ForceReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ab4f76bf224f2b4d8735f59db902c37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1ShaderAssetPostProcessor.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,283 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
public class AllIn1ShaderGradientDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
private int resolution;
|
||||
private Texture2D textureAsset;
|
||||
private static MethodInfo reinitializeMethod;
|
||||
private static MethodInfo resizeMethod;
|
||||
|
||||
public AllIn1ShaderGradientDrawer()
|
||||
{
|
||||
resolution = 64;
|
||||
}
|
||||
|
||||
public AllIn1ShaderGradientDrawer(float res)
|
||||
{
|
||||
resolution = (int)res;
|
||||
}
|
||||
|
||||
private static bool IsPropertyTypeSuitable(MaterialProperty prop)
|
||||
{
|
||||
AllIn1ShaderPropertyType propertyType = EditorUtils.GetShaderTypeByMaterialProperty(prop);
|
||||
return propertyType == AllIn1ShaderPropertyType.Texture;
|
||||
}
|
||||
|
||||
private string TextureName(MaterialProperty prop) => $"z{prop.name}Tex";
|
||||
private string OldName(MaterialProperty prop) => $"{prop.name}Tex";
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
|
||||
{
|
||||
if (!IsPropertyTypeSuitable(prop))
|
||||
{
|
||||
EditorGUI.HelpBox(position, $"[Gradient] used on non-texture property \"{prop.name}\"", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AssetDatabase.Contains(prop.targets.FirstOrDefault()))
|
||||
{
|
||||
EditorGUI.HelpBox(position, "Save Material To Folder to use this effect. Or use the regular Color Ramp instead", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
string textureName = TextureName(prop);
|
||||
string oldTextureName = OldName(prop);
|
||||
|
||||
Gradient currentGradient = null;
|
||||
if (prop.targets.Length == 1)
|
||||
{
|
||||
Material target = (Material)prop.targets[0];
|
||||
string path = AssetDatabase.GetAssetPath(target);
|
||||
textureAsset = GetTexture(path, textureName, oldTextureName);
|
||||
if (textureAsset != null) currentGradient = DecodeGradient(prop, textureAsset.name);
|
||||
if (currentGradient == null) currentGradient = new Gradient() { };
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.showMixedValue = true;
|
||||
}
|
||||
|
||||
using (EditorGUI.ChangeCheckScope changeScope = new EditorGUI.ChangeCheckScope())
|
||||
{
|
||||
currentGradient = EditorGUILayout.GradientField(label, currentGradient, GUILayout.Height(15));
|
||||
|
||||
if (changeScope.changed)
|
||||
{
|
||||
string encodedGradient = EncodeGradient(currentGradient);
|
||||
string fullAssetName = textureName + encodedGradient;
|
||||
foreach (Object target in prop.targets)
|
||||
{
|
||||
if (!AssetDatabase.Contains(target)) continue;
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(target);
|
||||
Texture2D textureAsset = GetTexture(path, textureName, oldTextureName);
|
||||
Undo.RecordObject(textureAsset, "Change Material Gradient");
|
||||
textureAsset.name = fullAssetName;
|
||||
BakeGradient(currentGradient, textureAsset);
|
||||
EditorUtility.SetDirty(textureAsset);
|
||||
|
||||
Material material = (Material)target;
|
||||
material.SetTexture(prop.name, textureAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUI.showMixedValue = false;
|
||||
}
|
||||
|
||||
private Texture2D GetTexture(string path, string name, string possibleOldName)
|
||||
{
|
||||
textureAsset = GetTextureAsset(path, name);
|
||||
if(textureAsset == null)
|
||||
{
|
||||
textureAsset = GetTextureAsset(path, possibleOldName);
|
||||
if(textureAsset != null)
|
||||
{
|
||||
textureAsset.name = textureAsset.name.Replace(possibleOldName, name);
|
||||
EditorUtility.SetDirty(textureAsset);
|
||||
}
|
||||
}
|
||||
if (textureAsset == null) CreateTexture(path, name);
|
||||
if(textureAsset.width != resolution)
|
||||
{
|
||||
ResizeTexture(textureAsset, resolution, 1);
|
||||
EditorUtility.SetDirty(textureAsset);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
return textureAsset;
|
||||
}
|
||||
|
||||
private void ResizeTexture(Texture2D texture, int width, int height)
|
||||
{
|
||||
if(reinitializeMethod == null && resizeMethod == null)
|
||||
{
|
||||
reinitializeMethod = typeof(Texture2D).GetMethod("Reinitialize", new[] { typeof(int), typeof(int) });
|
||||
if(reinitializeMethod == null) resizeMethod = typeof(Texture2D).GetMethod("Resize", new[] { typeof(int), typeof(int) });
|
||||
}
|
||||
|
||||
if(reinitializeMethod != null) reinitializeMethod.Invoke(texture, new object[] { width, height });
|
||||
else if(resizeMethod != null) resizeMethod.Invoke(texture, new object[] { width, height });
|
||||
}
|
||||
|
||||
private void CreateTexture(string path, string name = "unnamed texture")
|
||||
{
|
||||
textureAsset = new Texture2D(resolution, 1, TextureFormat.RGBA32, false);
|
||||
textureAsset.wrapMode = TextureWrapMode.Clamp;
|
||||
textureAsset.filterMode = FilterMode.Bilinear;
|
||||
textureAsset.name = name;
|
||||
AssetDatabase.AddObjectToAsset(textureAsset, path);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private string EncodeGradient(Gradient gradient)
|
||||
{
|
||||
if (gradient == null) return null;
|
||||
return JsonUtility.ToJson(new GradientRepresentation(gradient));
|
||||
}
|
||||
|
||||
private Gradient DecodeGradient(MaterialProperty prop, string name)
|
||||
{
|
||||
string json = name.Substring(TextureName(prop).Length);
|
||||
try
|
||||
{
|
||||
return JsonUtility.FromJson<GradientRepresentation>(json).ToGradient();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Texture2D GetTextureAsset(string path, string name)
|
||||
{
|
||||
return AssetDatabase.LoadAllAssetsAtPath(path).FirstOrDefault(asset => asset.name.StartsWith(name)) as Texture2D;
|
||||
}
|
||||
|
||||
private void BakeGradient(Gradient gradient, Texture2D texture)
|
||||
{
|
||||
if (gradient == null) return;
|
||||
for (int x = 0; x < texture.width; x++)
|
||||
{
|
||||
Color color = gradient.Evaluate((float)x / (texture.width - 1));
|
||||
for (int y = 0; y < texture.height; y++) texture.SetPixel(x, y, color);
|
||||
}
|
||||
texture.Apply();
|
||||
}
|
||||
|
||||
[MenuItem("Assets/AllIn1Shader Gradients/Remove All Gradient Textures")]
|
||||
static void RemoveAllSubassets()
|
||||
{
|
||||
foreach(Object asset in Selection.GetFiltered<Object>(SelectionMode.Assets))
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(asset);
|
||||
AssetDatabase.ImportAsset(path);
|
||||
foreach(Object subAsset in AssetDatabase.LoadAllAssetRepresentationsAtPath(path))
|
||||
{
|
||||
Object.DestroyImmediate(subAsset, true);
|
||||
}
|
||||
AssetDatabase.ImportAsset(path);
|
||||
}
|
||||
}
|
||||
|
||||
class GradientRepresentation
|
||||
{
|
||||
public GradientMode mode;
|
||||
public ColorKey[] colorKeys;
|
||||
public AlphaKey[] alphaKeys;
|
||||
|
||||
public GradientRepresentation() { }
|
||||
|
||||
public GradientRepresentation(Gradient source)
|
||||
{
|
||||
FromGradient(source);
|
||||
}
|
||||
|
||||
private void FromGradient(Gradient source)
|
||||
{
|
||||
mode = source.mode;
|
||||
colorKeys = source.colorKeys.Select(key => new ColorKey(key)).ToArray();
|
||||
alphaKeys = source.alphaKeys.Select(key => new AlphaKey(key)).ToArray();
|
||||
}
|
||||
|
||||
private void ToGradient(Gradient gradient)
|
||||
{
|
||||
gradient.mode = mode;
|
||||
gradient.colorKeys = colorKeys.Select(key => key.ToGradientKey()).ToArray();
|
||||
gradient.alphaKeys = alphaKeys.Select(key => key.ToGradientKey()).ToArray();
|
||||
}
|
||||
|
||||
public Gradient ToGradient()
|
||||
{
|
||||
Gradient gradient = new Gradient();
|
||||
ToGradient(gradient);
|
||||
return gradient;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct ColorKey
|
||||
{
|
||||
public Color color;
|
||||
public float time;
|
||||
|
||||
public ColorKey(GradientColorKey source)
|
||||
{
|
||||
color = default;
|
||||
time = default;
|
||||
FromGradientKey(source);
|
||||
}
|
||||
|
||||
public void FromGradientKey(GradientColorKey source)
|
||||
{
|
||||
color = source.color;
|
||||
time = source.time;
|
||||
}
|
||||
|
||||
public GradientColorKey ToGradientKey()
|
||||
{
|
||||
GradientColorKey key;
|
||||
key.color = color;
|
||||
key.time = time;
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct AlphaKey
|
||||
{
|
||||
public float alpha;
|
||||
public float time;
|
||||
|
||||
public AlphaKey(GradientAlphaKey source)
|
||||
{
|
||||
alpha = default;
|
||||
time = default;
|
||||
FromGradientKey(source);
|
||||
}
|
||||
|
||||
public void FromGradientKey(GradientAlphaKey source)
|
||||
{
|
||||
alpha = source.alpha;
|
||||
time = source.time;
|
||||
}
|
||||
|
||||
public GradientAlphaKey ToGradientKey()
|
||||
{
|
||||
GradientAlphaKey key;
|
||||
key.alpha = alpha;
|
||||
key.time = time;
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c51263ea47edd3641a26e5f242925bcf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1ShaderGradientDrawer.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,221 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public static class AllIn1ShaderImporter
|
||||
{
|
||||
public enum UnityVersion
|
||||
{
|
||||
NONE = 0,
|
||||
UNITY_2019 = 1,
|
||||
UNITY_2020 = 2,
|
||||
UNITY_2021 = 3,
|
||||
UNITY_2022 = 4,
|
||||
UNITY_6 = 5,
|
||||
}
|
||||
|
||||
public enum RenderPipeline
|
||||
{
|
||||
NONE = -1,
|
||||
BIRP = 0,
|
||||
URP = 1,
|
||||
HDRP = 2,
|
||||
}
|
||||
|
||||
|
||||
private const string SHADER_FOLDER_PATH = "../../Shaders/LitShaders";
|
||||
private const string FINAL_SHADERS_FOLDER_PATH = "../../Shaders";
|
||||
private const string SHADER_TEMPLATE_NAME = @"{0}_{1}.txt";
|
||||
|
||||
private const string SPRITE_LIT_SHADER_NAME = "AllIn1SpriteShaderLit";
|
||||
private const string SPRITE_LIT_TRANSPARENT_SHADER_NAME = "AllIn1SpriteShaderLitTransparent";
|
||||
|
||||
private const string PIPELINE_SUFFIX_URP_2019 = "BetterShader_URP2019";
|
||||
private const string PIPELINE_SUFFIX_HDRP_2019 = "BetterShader_HDRP2019";
|
||||
|
||||
private const string PIPELINE_SUFFIX_URP_2020 = "BetterShader_URP2020";
|
||||
private const string PIPELINE_SUFFIX_HDRP_2020 = "BetterShader_HDRP2020";
|
||||
|
||||
private const string PIPELINE_SUFFIX_URP_2021 = "BetterShader_URP2021";
|
||||
private const string PIPELINE_SUFFIX_HDRP_2021 = "BetterShader_HDRP2021";
|
||||
|
||||
private const string PIPELINE_SUFFIX_URP_2022 = "BetterShader_URP2022";
|
||||
private const string PIPELINE_SUFFIX_HDRP_2022 = "BetterShader_HDRP2022";
|
||||
|
||||
private const string PIPELINE_SUFFIX_URP_2023 = "BetterShader_URP2023";
|
||||
private const string PIPELINE_SUFFIX_HDRP_2023 = "BetterShader_HDRP2023";
|
||||
|
||||
private const string PIPELINE_SUFFIX_STANDARD = "BetterShader_Standard";
|
||||
|
||||
private const string LIT_SHADER_PIPELINE_KEY = "AllIn1SpriteShader_LitShader_RenderPipeline";
|
||||
private const string LIT_SHADER_UNITY_VERSION_KEY = "AllIn1SpriteShader_LitShader_UnityVersion";
|
||||
private const string LIT_SHADER_FIRST_TIME_PROJECT = "AllIn1SpriteShader_LitShader_FirstTimeProject";
|
||||
|
||||
static AllIn1ShaderImporter()
|
||||
{
|
||||
ConfigureShaders();
|
||||
}
|
||||
|
||||
private static void ConfigureShaders()
|
||||
{
|
||||
RenderPipelineChecker.RefreshData();
|
||||
|
||||
UnityVersion unityVersion = GetUnityVersion();
|
||||
RenderPipeline renderPipeline = GetRenderPipeline();
|
||||
|
||||
RenderPipeline lastRenderPipeline = (RenderPipeline)SessionState.GetInt(LIT_SHADER_PIPELINE_KEY, -1);
|
||||
UnityVersion lastUnityVersion = (UnityVersion)SessionState.GetInt(LIT_SHADER_UNITY_VERSION_KEY, 0);
|
||||
int firstTimeProject = SessionState.GetInt(LIT_SHADER_FIRST_TIME_PROJECT, -1);
|
||||
|
||||
if (lastRenderPipeline != renderPipeline || lastUnityVersion != unityVersion || firstTimeProject != 1)
|
||||
{
|
||||
SessionState.SetInt(LIT_SHADER_PIPELINE_KEY, (int)renderPipeline);
|
||||
SessionState.SetInt(LIT_SHADER_UNITY_VERSION_KEY, (int)unityVersion);
|
||||
SessionState.SetInt(LIT_SHADER_FIRST_TIME_PROJECT, 1);
|
||||
|
||||
ConfigureShader(SPRITE_LIT_SHADER_NAME);
|
||||
ConfigureShader(SPRITE_LIT_TRANSPARENT_SHADER_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConfigureShader(string shaderName)
|
||||
{
|
||||
string pipelineSufix = string.Empty;
|
||||
|
||||
UnityVersion unityVersion = GetUnityVersion();
|
||||
RenderPipeline renderPipeline = GetRenderPipeline();
|
||||
|
||||
if (renderPipeline == RenderPipeline.HDRP)
|
||||
{
|
||||
switch (unityVersion)
|
||||
{
|
||||
case UnityVersion.UNITY_2019:
|
||||
pipelineSufix = PIPELINE_SUFFIX_HDRP_2019;
|
||||
break;
|
||||
case UnityVersion.UNITY_2020:
|
||||
pipelineSufix = PIPELINE_SUFFIX_HDRP_2020;
|
||||
break;
|
||||
case UnityVersion.UNITY_2021:
|
||||
pipelineSufix = PIPELINE_SUFFIX_HDRP_2021;
|
||||
break;
|
||||
case UnityVersion.UNITY_2022:
|
||||
pipelineSufix = PIPELINE_SUFFIX_HDRP_2022;
|
||||
break;
|
||||
case UnityVersion.UNITY_6:
|
||||
pipelineSufix = PIPELINE_SUFFIX_HDRP_2023;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else if (renderPipeline == RenderPipeline.URP)
|
||||
{
|
||||
switch (unityVersion)
|
||||
{
|
||||
case UnityVersion.UNITY_2019:
|
||||
pipelineSufix = PIPELINE_SUFFIX_URP_2019;
|
||||
break;
|
||||
case UnityVersion.UNITY_2020:
|
||||
pipelineSufix = PIPELINE_SUFFIX_URP_2020;
|
||||
break;
|
||||
case UnityVersion.UNITY_2021:
|
||||
pipelineSufix = PIPELINE_SUFFIX_URP_2021;
|
||||
break;
|
||||
case UnityVersion.UNITY_2022:
|
||||
pipelineSufix = PIPELINE_SUFFIX_URP_2022;
|
||||
break;
|
||||
case UnityVersion.UNITY_6:
|
||||
pipelineSufix = PIPELINE_SUFFIX_URP_2023;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pipelineSufix = PIPELINE_SUFFIX_STANDARD;
|
||||
}
|
||||
|
||||
string templateFileName = string.Format(SHADER_TEMPLATE_NAME, shaderName, pipelineSufix);
|
||||
|
||||
string shaderTemplatePath = SHADER_FOLDER_PATH + "/" + templateFileName;
|
||||
string finalShaderPath = FINAL_SHADERS_FOLDER_PATH + "/" + $"{shaderName}.shader";
|
||||
|
||||
try
|
||||
{
|
||||
var currentFileGUID = AssetDatabase.FindAssets($"t:Script {nameof(AllIn1ShaderImporter)}")[0];
|
||||
string currentFolder = Path.GetDirectoryName(AssetDatabase.GUIDToAssetPath(currentFileGUID));
|
||||
|
||||
string newShaderStr = File.ReadAllText(Path.Combine(currentFolder, shaderTemplatePath));
|
||||
newShaderStr = newShaderStr.Replace($"Shader \"AllIn1SpriteShader/{shaderName}_BetterShader\"", $"Shader \"AllIn1SpriteShader/{shaderName}\"");
|
||||
|
||||
File.WriteAllText(Path.Combine(currentFolder, finalShaderPath), EditorUtils.UnifyEOL(newShaderStr));
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError("Shader not found: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private static UnityVersion GetUnityVersion()
|
||||
{
|
||||
UnityVersion res = UnityVersion.NONE;
|
||||
|
||||
string unityVersion = Application.unityVersion;
|
||||
|
||||
if (unityVersion.Contains("2019"))
|
||||
{
|
||||
res = UnityVersion.UNITY_2019;
|
||||
}
|
||||
else if (unityVersion.Contains("2020"))
|
||||
{
|
||||
res = UnityVersion.UNITY_2020;
|
||||
}
|
||||
else if (unityVersion.Contains("2021"))
|
||||
{
|
||||
res = UnityVersion.UNITY_2021;
|
||||
}
|
||||
else if (unityVersion.Contains("2022"))
|
||||
{
|
||||
res = UnityVersion.UNITY_2022;
|
||||
}
|
||||
else if (unityVersion.Contains("6000"))
|
||||
{
|
||||
res = UnityVersion.UNITY_6;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static RenderPipeline GetRenderPipeline()
|
||||
{
|
||||
RenderPipeline res = RenderPipeline.BIRP;
|
||||
|
||||
if (RenderPipelineChecker.IsURP)
|
||||
{
|
||||
res = RenderPipeline.URP;
|
||||
}
|
||||
else if (RenderPipelineChecker.IsHDRP)
|
||||
{
|
||||
res = RenderPipeline.HDRP;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void ForceReimport()
|
||||
{
|
||||
SessionState.EraseInt(LIT_SHADER_PIPELINE_KEY);
|
||||
SessionState.EraseInt(LIT_SHADER_UNITY_VERSION_KEY);
|
||||
SessionState.EraseInt(LIT_SHADER_FIRST_TIME_PROJECT);
|
||||
|
||||
ConfigureShaders();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa9d501412652444c8b5b573248c31be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1ShaderImporter.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
public enum AllIn1ShaderPropertyType
|
||||
{
|
||||
Color,
|
||||
Vector,
|
||||
Float,
|
||||
Range,
|
||||
Texture,
|
||||
Int,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 292320b1088d1734184f5459f884be05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1ShaderPropertyType.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,327 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using ShaderType = AllIn1SpriteShader.AllIn1Shader.ShaderTypes;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
[CustomEditor(typeof(AllIn1Shader)), CanEditMultipleObjects]
|
||||
public class AllIn1ShaderScriptEditor : UnityEditor.Editor
|
||||
{
|
||||
private bool showUrpWarning = false;
|
||||
private double warningTime = 0f;
|
||||
private SerializedProperty m_NormalStrength, m_NormalSmoothing;
|
||||
private Texture2D imageInspector;
|
||||
|
||||
private enum ImageType
|
||||
{
|
||||
ShowImage,
|
||||
HideInComponent,
|
||||
HideEverywhere
|
||||
}
|
||||
private ImageType imageType;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_NormalStrength = serializedObject.FindProperty("normalStrength");
|
||||
m_NormalSmoothing = serializedObject.FindProperty("normalSmoothing");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
ChooseAndDisplayAssetImage();
|
||||
|
||||
AllIn1Shader myScript = (AllIn1Shader)target;
|
||||
|
||||
SetCurrentShaderType(myScript);
|
||||
|
||||
if (GUILayout.Button("Deactivate All Effects"))
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++) ((AllIn1Shader)targets[i]).ClearAllKeywords();
|
||||
AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Deactivated All Effects");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("New Clean Material"))
|
||||
{
|
||||
bool successOperation = true;
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
successOperation &= ((AllIn1Shader)targets[i]).TryCreateNew();
|
||||
}
|
||||
if(successOperation) AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Clean Material");
|
||||
}
|
||||
|
||||
|
||||
if (GUILayout.Button("Create New Material With Same Properties (SEE DOC)"))
|
||||
{
|
||||
bool successOperation = true;
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
successOperation &= ((AllIn1Shader)targets[i]).MakeCopy();
|
||||
}
|
||||
if(successOperation) AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Copy Created");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Save Material To Folder (SEE DOC)"))
|
||||
{
|
||||
bool successOperation = true;
|
||||
for(int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
successOperation &= ((AllIn1Shader) targets[i]).SaveMaterial();
|
||||
}
|
||||
if(successOperation) AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Material Saved");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Apply Material To All Children"))
|
||||
{
|
||||
bool successOperation = true;
|
||||
for(int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
successOperation &= ((AllIn1Shader) targets[i]).ApplyMaterialToHierarchy();
|
||||
}
|
||||
if(successOperation) AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Material Applied To Children");
|
||||
else EditorUtility.DisplayDialog("No children found", "All In 1 Shader component couldn't find any children to this GameObject (" + targets[0].name + ")", "Ok");
|
||||
}
|
||||
|
||||
if (myScript.currentShaderType != AllIn1Shader.ShaderTypes.Urp2dRenderer)
|
||||
{
|
||||
if (GUILayout.Button("Render Material To Image"))
|
||||
{
|
||||
bool successOperation = true;
|
||||
for(int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
successOperation &= ((AllIn1Shader) targets[i]).RenderToImage();
|
||||
}
|
||||
if(successOperation) AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Material Rendered To Image");
|
||||
}
|
||||
}
|
||||
|
||||
bool isUrp = false;
|
||||
Shader temp = AllIn1ShaderWindow.FindShader("AllIn1Urp2dRenderer");
|
||||
if (temp != null) isUrp = true;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Change Shader Variant:", GUILayout.MaxWidth(140));
|
||||
int previousShaderType = (int)myScript.currentShaderType;
|
||||
myScript.currentShaderType = (AllIn1Shader.ShaderTypes)EditorGUILayout.EnumPopup(myScript.currentShaderType);
|
||||
if (previousShaderType != (int)myScript.currentShaderType)
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++) ((AllIn1Shader)targets[i]).CheckIfValidTarget();
|
||||
if (myScript == null) return;
|
||||
if (isUrp || myScript.currentShaderType != AllIn1Shader.ShaderTypes.Urp2dRenderer)
|
||||
{
|
||||
AllIn1ShaderWindow.SceneViewNotificationAndLog(myScript.gameObject.name + " shader variant has been changed to: " + myScript.currentShaderType);
|
||||
myScript.SetSceneDirty();
|
||||
|
||||
Renderer sr = myScript.GetComponent<Renderer>();
|
||||
if (sr != null)
|
||||
{
|
||||
if (sr.sharedMaterial != null)
|
||||
{
|
||||
int renderingQueue = sr.sharedMaterial.renderQueue;
|
||||
if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.Default) sr.sharedMaterial.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShader");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.ScaledTime) sr.sharedMaterial.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderScaledTime");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.MaskedUI) sr.sharedMaterial.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderUiMask");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.Urp2dRenderer) sr.sharedMaterial.shader = AllIn1ShaderWindow.FindShader("AllIn1Urp2dRenderer");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.Lit) sr.sharedMaterial.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderLit");
|
||||
else if(myScript.currentShaderType == AllIn1Shader.ShaderTypes.SRPBatcher) sr.sharedMaterial.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderSRPBatch");
|
||||
else SetCurrentShaderType(myScript);
|
||||
sr.sharedMaterial.renderQueue = renderingQueue;
|
||||
|
||||
if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.Lit)
|
||||
{
|
||||
sr.sharedMaterial.SetFloat("_ZWrite", 1.0f);
|
||||
sr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
|
||||
sr.receiveShadows = true;
|
||||
sr.sharedMaterial.renderQueue = 2000;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.sharedMaterial.SetFloat("_ZWrite", 0f);
|
||||
sr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||
sr.receiveShadows = false;
|
||||
sr.sharedMaterial.renderQueue = 3000;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphic img = myScript.GetComponent<Graphic>();
|
||||
if (img != null && img.material != null)
|
||||
{
|
||||
int renderingQueue = img.material.renderQueue;
|
||||
if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.Default) img.material.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShader");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.ScaledTime) img.material.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderScaledTime");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.MaskedUI) img.material.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderUiMask");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.Urp2dRenderer) img.material.shader = AllIn1ShaderWindow.FindShader("AllIn1Urp2dRenderer");
|
||||
else if (myScript.currentShaderType == AllIn1Shader.ShaderTypes.Lit) img.material.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderLit");
|
||||
else if(myScript.currentShaderType == AllIn1Shader.ShaderTypes.SRPBatcher) img.material.shader = AllIn1ShaderWindow.FindShader("AllIn1SpriteShaderSRPBatch");
|
||||
else SetCurrentShaderType(myScript);
|
||||
img.material.renderQueue = renderingQueue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!isUrp && myScript.currentShaderType == AllIn1Shader.ShaderTypes.Urp2dRenderer)
|
||||
{
|
||||
myScript.currentShaderType = (AllIn1Shader.ShaderTypes) previousShaderType;
|
||||
showUrpWarning = true;
|
||||
warningTime = EditorApplication.timeSinceStartup + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (warningTime < EditorApplication.timeSinceStartup) showUrpWarning = false;
|
||||
if (isUrp) showUrpWarning = false;
|
||||
if (showUrpWarning) EditorGUILayout.HelpBox(
|
||||
"You can't set the URP 2D Renderer variant since you didn't import the URP package available in the asset root folder (SEE DOCUMENTATION)",
|
||||
MessageType.Error,
|
||||
true);
|
||||
|
||||
if ((isUrp && myScript.currentShaderType == AllIn1Shader.ShaderTypes.Urp2dRenderer) || myScript.currentShaderType == AllIn1Shader.ShaderTypes.Lit)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Create And Add Normal Map"))
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++) ((AllIn1Shader)targets[i]).CreateAndAssignNormalMap();
|
||||
AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Creating Normal Map");
|
||||
|
||||
}
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_NormalStrength, new GUIContent("Normal Strength"), GUILayout.Height(20));
|
||||
EditorGUILayout.PropertyField(m_NormalSmoothing, new GUIContent("Normal Blur"), GUILayout.Height(20));
|
||||
if (myScript.computingNormal)
|
||||
{
|
||||
EditorGUILayout.LabelField("Normal Map is currently being created, be patient", EditorStyles.boldLabel, GUILayout.Height(40));
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Sprite Atlas Auto Setup"))
|
||||
{
|
||||
bool successOperation = true;
|
||||
for(int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
successOperation &= ((AllIn1Shader) targets[i]).ToggleSetAtlasUvs(true);
|
||||
}
|
||||
if(successOperation) AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Sprite Atlas Auto Setup");
|
||||
}
|
||||
if (GUILayout.Button("Remove Sprite Atlas Configuration"))
|
||||
{
|
||||
bool successOperation = true;
|
||||
for(int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
successOperation &= ((AllIn1Shader) targets[i]).ToggleSetAtlasUvs(false);
|
||||
}
|
||||
if(successOperation) AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Remove Sprite Atlas Configuration");
|
||||
}
|
||||
|
||||
#if LETAI_TRUESHADOW
|
||||
if (myScript.GetComponent<LeTai.TrueShadow.TrueShadow>() && !myScript.GetComponent<TrueShadowCompatibility>())
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
if (GUILayout.Button("Add True Shadow Compatibility"))
|
||||
{
|
||||
myScript.gameObject.AddComponent<TrueShadowCompatibility>();
|
||||
myScript.SetSceneDirty();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
EditorGUILayout.Space();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
|
||||
if(GUILayout.Button("Remove Component"))
|
||||
{
|
||||
for(int i = targets.Length - 1; i >= 0; i--)
|
||||
{
|
||||
DestroyImmediate(targets[i] as AllIn1Shader);
|
||||
((AllIn1Shader)targets[i]).SetSceneDirty();
|
||||
}
|
||||
AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Component Removed");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("REMOVE COMPONENT AND MATERIAL"))
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
((AllIn1Shader)targets[i]).CleanMaterial();
|
||||
}
|
||||
for (int i = targets.Length - 1; i >= 0; i--)
|
||||
{
|
||||
DestroyImmediate(targets[i] as AllIn1Shader);
|
||||
}
|
||||
AllIn1ShaderWindow.ShowSceneViewNotification("AllIn1SpriteShader: Component And Material Removed");
|
||||
}
|
||||
}
|
||||
|
||||
private void ChooseAndDisplayAssetImage()
|
||||
{
|
||||
if(!EditorPrefs.HasKey("allIn1ImageConfig"))
|
||||
{
|
||||
EditorPrefs.SetInt("allIn1ImageConfig", (int) ImageType.ShowImage);
|
||||
}
|
||||
|
||||
imageType = (ImageType) EditorPrefs.GetInt("allIn1ImageConfig");
|
||||
switch(imageType)
|
||||
{
|
||||
case ImageType.ShowImage:
|
||||
case ImageType.HideInComponent:
|
||||
if(imageInspector == null) imageInspector = AllIn1ShaderWindow.GetInspectorImage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(imageInspector && imageType != ImageType.HideInComponent && imageType != ImageType.HideEverywhere && imageInspector)
|
||||
{
|
||||
Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(40));
|
||||
GUI.DrawTexture(rect, imageInspector, ScaleMode.ScaleToFit, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCurrentShaderType(AllIn1Shader myScript)
|
||||
{
|
||||
string shaderName = "";
|
||||
Renderer sr = myScript.GetComponent<Renderer>();
|
||||
if (sr != null)
|
||||
{
|
||||
if(sr.sharedMaterial == null) return;
|
||||
shaderName = sr.sharedMaterial.shader.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphic img = myScript.GetComponent<Graphic>();
|
||||
if(img.material == null) return;
|
||||
if (img != null) shaderName = img.material.shader.name;
|
||||
}
|
||||
shaderName = shaderName.Replace("AllIn1SpriteShader/", "");
|
||||
|
||||
if (shaderName.Equals("AllIn1SpriteShader")) myScript.currentShaderType = AllIn1Shader.ShaderTypes.Default;
|
||||
else if (shaderName.Equals("AllIn1SpriteShaderScaledTime")) myScript.currentShaderType = AllIn1Shader.ShaderTypes.ScaledTime;
|
||||
else if (shaderName.Equals("AllIn1SpriteShaderUiMask")) myScript.currentShaderType = AllIn1Shader.ShaderTypes.MaskedUI;
|
||||
else if (shaderName.Equals("AllIn1Urp2dRenderer")) myScript.currentShaderType = AllIn1Shader.ShaderTypes.Urp2dRenderer;
|
||||
else if(shaderName.Equals("AllIn1SpriteShaderLit")) myScript.currentShaderType = AllIn1Shader.ShaderTypes.Lit;
|
||||
else if(shaderName.Equals("AllIn1SpriteShaderSRPBatch")) myScript.currentShaderType = AllIn1Shader.ShaderTypes.SRPBatcher;
|
||||
}
|
||||
|
||||
private void DrawLine(Color color, int thickness = 2, int padding = 10)
|
||||
{
|
||||
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
|
||||
r.height = thickness;
|
||||
r.y += (padding / 2);
|
||||
r.x -= 2;
|
||||
r.width += 6;
|
||||
EditorGUI.DrawRect(r, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78232fc1cf0e9c445a36b7bf7fc49fdb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1ShaderScriptEditor.cs
|
||||
uploadId: 857600
|
||||
+850
@@ -0,0 +1,850 @@
|
||||
#if UNITY_EDITOR
|
||||
using AllIn1SpriteShader;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
public class AllIn1SpriteShaderLitMaterialInspector : ShaderGUI
|
||||
{
|
||||
private Material targetMat;
|
||||
private BlendMode srcMode, dstMode;
|
||||
private CompareFunction zTestMode = CompareFunction.LessEqual;
|
||||
private CullMode cullMode;
|
||||
|
||||
private GUIStyle propertiesStyle, bigLabelStyle, smallLabelStyle, toggleButtonStyle;
|
||||
private const int bigFontSize = 16, smallFontSize = 11;
|
||||
private string[] oldKeyWords;
|
||||
private int effectCount = 1;
|
||||
private Material originalMaterialCopy;
|
||||
private MaterialEditor matEditor;
|
||||
private MaterialProperty[] matProperties;
|
||||
private uint[] materialDrawers = new uint[] { 1, 2, 4 };
|
||||
bool[] currEnabledDrawers;
|
||||
private const uint advancedConfigDrawer = 0;
|
||||
private const uint colorFxShapeDrawer = 1;
|
||||
private const uint uvFxShapeDrawer = 2;
|
||||
|
||||
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
matEditor = materialEditor;
|
||||
matProperties = properties;
|
||||
targetMat = materialEditor.target as Material;
|
||||
effectCount = 1;
|
||||
oldKeyWords = targetMat.shaderKeywords;
|
||||
propertiesStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
propertiesStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
bigLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
bigLabelStyle.fontSize = bigFontSize;
|
||||
smallLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
smallLabelStyle.fontSize = smallFontSize;
|
||||
toggleButtonStyle = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleCenter, richText = true };
|
||||
currEnabledDrawers = new bool[materialDrawers.Length];
|
||||
uint iniDrawers = (uint)ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue;
|
||||
for(int i = 0; i < materialDrawers.Length; i++) currEnabledDrawers[i] = (materialDrawers[i] & iniDrawers) > 0;
|
||||
|
||||
GUILayout.Label("General Properties", bigLabelStyle);
|
||||
DrawProperty(0);
|
||||
DrawProperty(172);
|
||||
|
||||
DrawProperty(1);
|
||||
//DrawProperty(2);
|
||||
DrawProperty(70);
|
||||
|
||||
currEnabledDrawers[advancedConfigDrawer] = GUILayout.Toggle(currEnabledDrawers[advancedConfigDrawer], new GUIContent("<size=12>Show Advanced Configuration</size>"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[advancedConfigDrawer])
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
Culling();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ZTest();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ZWrite();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
Billboard("Billboard active", "BILBOARD_ON");
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
SpriteAtlas("Sprite inside an atlas?", "ATLAS_ON");
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.EnableInstancingField();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.RenderQueueField();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("Light Effect", bigLabelStyle);
|
||||
GenericEffect("Normal Map", "NORMALMAP_ON", 189, 190);
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("Color Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[colorFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[colorFxShapeDrawer], new GUIContent("Show Color Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[colorFxShapeDrawer])
|
||||
{
|
||||
Glow("Glow", "GLOW_ON");
|
||||
GenericEffect("Fade", "FADE_ON", 7, 13, extraProperties: new int[] { 173, 174 } );
|
||||
Outline("Outline", "OUTBASE_ON");
|
||||
GenericEffect("Alpha Outline", "ALPHAOUTLINE_ON", 26, 30, true, "A more performant but less flexible outline");
|
||||
InnerOutline("Inner Outline", "INNEROUTLINE_ON", 66, 69);
|
||||
Gradient("Gradient & Radial Gradient", "GRADIENT_ON");
|
||||
GenericEffect("Color Swap", "COLORSWAP_ON", 36, 42, true, "You will need a mask texture (see Documentation)", new int[] { 154 });
|
||||
GenericEffect("Hue Shift", "HSV_ON", 43, 45);
|
||||
ColorChange("Change 1 Color", "CHANGECOLOR_ON");
|
||||
ColorRamp("Color Ramp", "COLORRAMP_ON");
|
||||
GenericEffect("Hit Effect", "HITEFFECT_ON", 46, 48);
|
||||
GenericEffect("Negative", "NEGATIVE_ON", 49, 49);
|
||||
GenericEffect("Pixelate", "PIXELATE_ON", 50, 50, true, "Looks bad with distorition effects");
|
||||
GreyScale("GreyScale", "GREYSCALE_ON");
|
||||
Posterize("Posterize", "POSTERIZE_ON");
|
||||
Blur("Blur", "BLUR_ON");
|
||||
GenericEffect("Motion Blur", "MOTIONBLUR_ON", 62, 63);
|
||||
GenericEffect("Ghost", "GHOST_ON", 64, 65, true, "This effect will not affect the outline", new int[] { 157 });
|
||||
GenericEffect("Hologram", "HOLOGRAM_ON", 73, 77, true, null, new int[] { 140, 158 });
|
||||
GenericEffect("Chromatic Aberration", "CHROMABERR_ON", 78, 79);
|
||||
GenericEffect("Glitch", "GLITCH_ON", 80, 80, true, null, new int[] { 139, 180 });
|
||||
GenericEffect("Flicker", "FLICKER_ON", 81, 83);
|
||||
GenericEffect("Shadow", "SHADOW_ON", 84, 87);
|
||||
GenericEffect("Shine", "SHINE_ON", 133, 138);
|
||||
GenericEffect("Contrast & Brightness", "CONTRAST_ON", 152, 153);
|
||||
Overlay("Overlay Texture", "OVERLAY_ON");
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("UV Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[uvFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[uvFxShapeDrawer], new GUIContent("Show UV Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[uvFxShapeDrawer])
|
||||
{
|
||||
GenericEffect("Hand Drawn", "DOODLE_ON", 88, 89);
|
||||
Grass("Grass Movement / Wind", "WIND_ON");
|
||||
GenericEffect("Wave", "WAVEUV_ON", 94, 98);
|
||||
GenericEffect("Round Wave", "ROUNDWAVEUV_ON", 127, 128);
|
||||
GenericEffect("Rect Size (Enable wireframe to see result)", "RECTSIZE_ON", 99, 99, true, "Only on single sprites spritesheets NOT supported");
|
||||
GenericEffect("Offset", "OFFSETUV_ON", 100, 101);
|
||||
GenericEffect("Clipping / Fill Amount", "CLIPPING_ON", 102, 105);
|
||||
GenericEffect("Radial Clipping / Radial Fill", "RADIALCLIPPING_ON", 164, 166);
|
||||
GenericEffect("Texture Scroll", "TEXTURESCROLL_ON", 106, 107, true, "Set Texture Wrap Mode to Repeat");
|
||||
GenericEffect("Zoom", "ZOOMUV_ON", 108, 108);
|
||||
GenericEffect("Distortion", "DISTORT_ON", 109, 112, extraProperties: new int[] { 177 } );
|
||||
GenericEffect("Warp Distortion", "WARP_ON", 167, 169);
|
||||
GenericEffect("Twist", "TWISTUV_ON", 113, 116);
|
||||
GenericEffect("Rotate", "ROTATEUV_ON", 117, 117, true, "_Tip_ Use Clipping effect to avoid possible undesired parts");
|
||||
GenericEffect("Polar Coordinates (Tile texture for good results)", "POLARUV_ON", -1, -1);
|
||||
GenericEffect("Fish Eye", "FISHEYE_ON", 118, 118);
|
||||
GenericEffect("Pinch", "PINCH_ON", 119, 119);
|
||||
GenericEffect("Shake", "SHAKEUV_ON", 120, 122);
|
||||
}
|
||||
|
||||
SetAndSaveEnabledDrawers(iniDrawers);
|
||||
}
|
||||
|
||||
private void SetAndSaveEnabledDrawers(uint iniDrawers)
|
||||
{
|
||||
uint currDrawers = 0;
|
||||
for(int i = 0; i < currEnabledDrawers.Length; i++)
|
||||
{
|
||||
if(currEnabledDrawers[i]) currDrawers |= materialDrawers[i];
|
||||
}
|
||||
|
||||
if(iniDrawers != currDrawers) ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue = currDrawers;
|
||||
}
|
||||
|
||||
private void Blending()
|
||||
{
|
||||
MaterialProperty srcM = ShaderGUI.FindProperty("_MySrcMode", matProperties);
|
||||
MaterialProperty dstM = ShaderGUI.FindProperty("_MyDstMode", matProperties);
|
||||
if(srcM.floatValue == 0 && dstM.floatValue == 0)
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
}
|
||||
|
||||
GUILayout.Label("This doesn't make much sense in a lit shader", smallLabelStyle);
|
||||
if(GUILayout.Button("Back To Default Blending"))
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
srcMode = (BlendMode)srcM.floatValue;
|
||||
dstMode = (BlendMode)dstM.floatValue;
|
||||
srcMode = (BlendMode)EditorGUILayout.EnumPopup("SrcMode", srcMode);
|
||||
dstMode = (BlendMode)EditorGUILayout.EnumPopup("DstMode", dstMode);
|
||||
srcM.floatValue = (float)(srcMode);
|
||||
dstM.floatValue = (float)(dstMode);
|
||||
|
||||
bool ini = oldKeyWords.Contains("PREMULTIPLYALPHA_ON");
|
||||
bool toggle = EditorGUILayout.Toggle("Premultiply Alpha?", ini);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle) targetMat.EnableKeyword("PREMULTIPLYALPHA_ON");
|
||||
else targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
private void Billboard(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = inspector;
|
||||
toggle = GUILayout.Toggle(toggle, effectNameLabel);
|
||||
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
GUILayout.Label("Don't use this feature on UI elements!", smallLabelStyle);
|
||||
DrawProperty(129, true);
|
||||
MaterialProperty billboardY = matProperties[129];
|
||||
if(billboardY.floatValue == 1) targetMat.EnableKeyword("BILBOARDY_ON");
|
||||
else targetMat.DisableKeyword("BILBOARDY_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
private void ZWrite()
|
||||
{
|
||||
MaterialProperty zWrite = ShaderGUI.FindProperty("_ZWrite", matProperties);
|
||||
bool toggle = zWrite.floatValue > 0.9f ? true : false;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
float tempValue = zWrite.floatValue;
|
||||
toggle = GUILayout.Toggle(toggle, new GUIContent("Enable Z Write"));
|
||||
if(toggle) zWrite.floatValue = 1.0f;
|
||||
else zWrite.floatValue = 0.0f;
|
||||
if(tempValue != zWrite.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void ZTest()
|
||||
{
|
||||
MaterialProperty zTestM = ShaderGUI.FindProperty("_ZTestMode", matProperties);
|
||||
float tempValue = zTestM.floatValue;
|
||||
zTestMode = (UnityEngine.Rendering.CompareFunction)zTestM.floatValue;
|
||||
zTestMode = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("Z TestMode", zTestMode);
|
||||
zTestM.floatValue = (float)(zTestMode);
|
||||
if(tempValue != zTestM.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
|
||||
private void Culling()
|
||||
{
|
||||
MaterialProperty cullO = ShaderGUI.FindProperty("_CullingOption", matProperties);
|
||||
;
|
||||
float tempValue = cullO.floatValue;
|
||||
cullMode = (UnityEngine.Rendering.CullMode)cullO.floatValue;
|
||||
cullMode = (UnityEngine.Rendering.CullMode)EditorGUILayout.EnumPopup("Culling Mode", cullMode);
|
||||
cullO.floatValue = (float)(cullMode);
|
||||
if(tempValue != cullO.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
|
||||
private void SpriteAtlas(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
toggle = GUILayout.Toggle(toggle, inspector);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("Make sure SpriteAtlasUV component is added \n " +
|
||||
"*Check documentation if unsure what this does or how it works", smallLabelStyle);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
private void Outline(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + ".Outline";
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("OUTBASE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(14);
|
||||
DrawProperty(15);
|
||||
DrawProperty(16);
|
||||
DrawEffectSubKeywordToggle("Outline High Resolution?", "OUTBASE8DIR_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlinePixelPerf = DrawEffectSubKeywordToggle("Outline is Pixel Perfect?", "OUTBASEPIXELPERF_ON");
|
||||
if(outlinePixelPerf) DrawProperty(18);
|
||||
else DrawProperty(17);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineTexture = DrawEffectSubKeywordToggle("Outline uses texture?", "OUTTEX_ON");
|
||||
if(outlineTexture)
|
||||
{
|
||||
DrawProperty(19);
|
||||
DrawProperty(175);
|
||||
DrawProperty(20);
|
||||
DrawProperty(21);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineDistort = DrawEffectSubKeywordToggle("Outline uses distortion?", "OUTDIST_ON");
|
||||
if(outlineDistort)
|
||||
{
|
||||
DrawProperty(22);
|
||||
DrawProperty(176);
|
||||
DrawProperty(23);
|
||||
DrawProperty(24);
|
||||
DrawProperty(25);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
DrawEffectSubKeywordToggle("Only render outline?", "ONLYOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("OUTBASE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GenericEffect(string inspector, string keyword, int first, int last, bool effectCounter = true, string preMessage = null, int[] extraProperties = null, bool boldToggleLetters = true)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
if(effectCounter)
|
||||
{
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
effectCount++;
|
||||
}
|
||||
else effectNameLabel.text = inspector;
|
||||
|
||||
if(boldToggleLetters) toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
else toggle = GUILayout.Toggle(toggle, effectNameLabel);
|
||||
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
if(preMessage != null) GUILayout.Label(preMessage, smallLabelStyle);
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
if(extraProperties != null)
|
||||
foreach(int i in extraProperties)
|
||||
DrawProperty(i);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
if(boldToggleLetters) EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Glow(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GLOW_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useGlowTex = DrawEffectSubKeywordToggle("Use Glow Texture?", "GLOWTEX_ON");
|
||||
if(useGlowTex) DrawProperty(6);
|
||||
|
||||
DrawProperty(3);
|
||||
DrawProperty(4);
|
||||
DrawProperty(5, true);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GLOW_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorRamp(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("COLORRAMP_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useEditableGradient = false;
|
||||
if(AssetDatabase.Contains(targetMat))
|
||||
{
|
||||
useEditableGradient = oldKeyWords.Contains("GRADIENTCOLORRAMP_ON");
|
||||
bool gradientTex = useEditableGradient;
|
||||
gradientTex = GUILayout.Toggle(gradientTex, new GUIContent("Use Editable Gradient?"));
|
||||
if(useEditableGradient != gradientTex)
|
||||
{
|
||||
Save();
|
||||
if(gradientTex)
|
||||
{
|
||||
useEditableGradient = true;
|
||||
targetMat.EnableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
|
||||
if(useEditableGradient) matEditor.ShaderProperty(matProperties[159], matProperties[159].displayName);
|
||||
}
|
||||
else GUILayout.Label("*Save to folder to allow for dynamic Gradient property", smallLabelStyle);
|
||||
|
||||
if(!useEditableGradient) DrawProperty(51);
|
||||
|
||||
DrawProperty(52);
|
||||
DrawProperty(53, true);
|
||||
MaterialProperty colorRampOut = matProperties[53];
|
||||
if(colorRampOut.floatValue == 1) targetMat.EnableKeyword("COLORRAMPOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("COLORRAMPOUTLINE_ON");
|
||||
DrawProperty(155);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("COLORRAMP_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorChange(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = 123; i < 127; i++) DrawProperty(i);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR2_ON");
|
||||
bool toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 2", ini);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR2_ON");
|
||||
for(int i = 146; i < 149; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR2_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR3_ON");
|
||||
toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 3", toggle2);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR3_ON");
|
||||
for(int i = 149; i < 152; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR3_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GreyScale(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GREYSCALE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(54);
|
||||
DrawProperty(56);
|
||||
DrawProperty(55, true);
|
||||
MaterialProperty greyScaleOut = matProperties[55];
|
||||
if(greyScaleOut.floatValue == 1) targetMat.EnableKeyword("GREYSCALEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("GREYSCALEOUTLINE_ON");
|
||||
DrawProperty(156);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GREYSCALE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Posterize(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("POSTERIZE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(57);
|
||||
DrawProperty(58);
|
||||
DrawProperty(59, true);
|
||||
MaterialProperty posterizeOut = matProperties[59];
|
||||
if(posterizeOut.floatValue == 1) targetMat.EnableKeyword("POSTERIZEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("POSTERIZEOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("POSTERIZE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Blur(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("BLUR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("This effect will not affect the outline", smallLabelStyle);
|
||||
DrawProperty(60);
|
||||
DrawProperty(61, true);
|
||||
MaterialProperty blurIsHd = matProperties[61];
|
||||
if(blurIsHd.floatValue == 1) targetMat.EnableKeyword("BLURISHD_ON");
|
||||
else targetMat.DisableKeyword("BLURISHD_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("BLUR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Grass(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("WIND_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(90);
|
||||
DrawProperty(91);
|
||||
DrawProperty(145);
|
||||
DrawProperty(92);
|
||||
DrawProperty(93, true);
|
||||
MaterialProperty grassManual = matProperties[92];
|
||||
if(grassManual.floatValue == 1) targetMat.EnableKeyword("MANUALWIND_ON");
|
||||
else targetMat.DisableKeyword("MANUALWIND_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("WIND_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void InnerOutline(string inspector, string keyword, int first, int last)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawProperty(72, true);
|
||||
MaterialProperty onlyInOutline = matProperties[72];
|
||||
if(onlyInOutline.floatValue == 1) targetMat.EnableKeyword("ONLYINNEROUTLINE_ON");
|
||||
else targetMat.DisableKeyword("ONLYINNEROUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Gradient(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(143, true);
|
||||
MaterialProperty gradIsRadial = matProperties[143];
|
||||
if(gradIsRadial.floatValue == 1)
|
||||
{
|
||||
targetMat.EnableKeyword("RADIALGRADIENT_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
DrawProperty(34);
|
||||
DrawProperty(141);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetMat.DisableKeyword("RADIALGRADIENT_ON");
|
||||
bool simpleGradient = oldKeyWords.Contains("GRADIENT2COL_ON");
|
||||
bool simpleGradToggle = EditorGUILayout.Toggle("2 Color Gradient?", simpleGradient);
|
||||
if(simpleGradient && !simpleGradToggle) targetMat.DisableKeyword("GRADIENT2COL_ON");
|
||||
else if(!simpleGradient && simpleGradToggle) targetMat.EnableKeyword("GRADIENT2COL_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
if(!simpleGradToggle) DrawProperty(33);
|
||||
DrawProperty(34);
|
||||
if(!simpleGradToggle) DrawProperty(35);
|
||||
if(!simpleGradToggle) DrawProperty(141);
|
||||
DrawProperty(142);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Overlay(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool multModeOn = oldKeyWords.Contains("OVERLAYMULT_ON");
|
||||
bool isMultMode = multModeOn;
|
||||
isMultMode = GUILayout.Toggle(isMultMode, new GUIContent("Is overlay multiplicative?"));
|
||||
if(multModeOn != isMultMode)
|
||||
{
|
||||
Save();
|
||||
if(isMultMode)
|
||||
{
|
||||
multModeOn = true;
|
||||
targetMat.EnableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
|
||||
if(multModeOn) GUILayout.Label("Overlay is set to multiplicative mode", smallLabelStyle);
|
||||
else GUILayout.Label("Overlay is set to additive mode", smallLabelStyle);
|
||||
|
||||
|
||||
DrawProperty(160);
|
||||
DrawProperty(178);
|
||||
DrawProperty(161);
|
||||
DrawProperty(162);
|
||||
DrawProperty(163);
|
||||
|
||||
for (int i = 170; i <= 171; i++)
|
||||
{
|
||||
DrawProperty(i);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void DrawProperty(int index, bool noReset = false)
|
||||
{
|
||||
MaterialProperty targetProperty = matProperties[index];
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = targetProperty.displayName;
|
||||
propertyLabel.tooltip = targetProperty.name + " (C#)";
|
||||
|
||||
matEditor.ShaderProperty(targetProperty, propertyLabel);
|
||||
|
||||
if(!noReset)
|
||||
{
|
||||
GUIContent resetButtonLabel = new GUIContent();
|
||||
resetButtonLabel.text = "R";
|
||||
resetButtonLabel.tooltip = "Resets to default value";
|
||||
if(GUILayout.Button(resetButtonLabel, GUILayout.Width(20))) ResetProperty(targetProperty);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void ResetProperty(MaterialProperty targetProperty)
|
||||
{
|
||||
AllIn1ShaderPropertyType shaderProperty = EditorUtils.GetShaderTypeByMaterialProperty(targetProperty);
|
||||
|
||||
if(originalMaterialCopy == null) originalMaterialCopy = new Material(targetMat.shader);
|
||||
if(shaderProperty == AllIn1ShaderPropertyType.Float || shaderProperty == AllIn1ShaderPropertyType.Range)
|
||||
{
|
||||
targetProperty.floatValue = originalMaterialCopy.GetFloat(targetProperty.name);
|
||||
}
|
||||
else if(shaderProperty == AllIn1ShaderPropertyType.Vector)
|
||||
{
|
||||
targetProperty.vectorValue = originalMaterialCopy.GetVector(targetProperty.name);
|
||||
}
|
||||
else if(shaderProperty == AllIn1ShaderPropertyType.Color)
|
||||
{
|
||||
targetProperty.colorValue = originalMaterialCopy.GetColor(targetProperty.name);
|
||||
}
|
||||
else if(shaderProperty == AllIn1ShaderPropertyType.Texture)
|
||||
{
|
||||
targetProperty.textureValue = originalMaterialCopy.GetTexture(targetProperty.name);
|
||||
}
|
||||
}
|
||||
|
||||
private bool DrawEffectSubKeywordToggle(string inspector, string keyword, bool setCustomConfigAfter = false)
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = inspector;
|
||||
propertyLabel.tooltip = keyword + " (C#)";
|
||||
|
||||
bool ini = oldKeyWords.Contains(keyword);
|
||||
bool toggle = ini;
|
||||
toggle = GUILayout.Toggle(toggle, propertyLabel);
|
||||
if(ini != toggle)
|
||||
{
|
||||
if(toggle) targetMat.EnableKeyword(keyword);
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
return toggle;
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
if(!Application.isPlaying) EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
EditorUtility.SetDirty(targetMat);
|
||||
}
|
||||
|
||||
private void DrawLine(Color color, int thickness = 2, int padding = 10)
|
||||
{
|
||||
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
|
||||
r.height = thickness;
|
||||
r.y += (padding / 2);
|
||||
r.x -= 2;
|
||||
r.width += 6;
|
||||
EditorGUI.DrawRect(r, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58a451704eab27348bd5177152dc656f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1SpriteShaderLitMaterialInspector.cs
|
||||
uploadId: 857600
|
||||
+884
@@ -0,0 +1,884 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Linq;
|
||||
using AllIn1SpriteShader;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
public class AllIn1SpriteShaderMaterialInspector : ShaderGUI
|
||||
{
|
||||
private Material targetMat;
|
||||
private BlendMode srcMode, dstMode;
|
||||
private CompareFunction zTestMode = CompareFunction.LessEqual;
|
||||
private CullMode cullMode;
|
||||
|
||||
private GUIStyle propertiesStyle, bigLabelStyle, smallLabelStyle, toggleButtonStyle;
|
||||
private const int bigFontSize = 16, smallFontSize = 11;
|
||||
private string[] oldKeyWords;
|
||||
private int effectCount = 1;
|
||||
private Material originalMaterialCopy;
|
||||
private MaterialEditor matEditor;
|
||||
private MaterialProperty[] matProperties;
|
||||
private uint[] materialDrawers = new uint[] { 1, 2, 4 };
|
||||
bool[] currEnabledDrawers;
|
||||
private const uint advancedConfigDrawer = 0;
|
||||
private const uint colorFxShapeDrawer = 1;
|
||||
private const uint uvFxShapeDrawer = 2;
|
||||
|
||||
public bool IsSRPShader()
|
||||
{
|
||||
bool res = false;
|
||||
if(targetMat != null)
|
||||
{
|
||||
res = targetMat.shader.name == "AllIn1SpriteShader/AllIn1SpriteShaderSRPBatch";
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
matEditor = materialEditor;
|
||||
matProperties = properties;
|
||||
targetMat = materialEditor.target as Material;
|
||||
effectCount = 1;
|
||||
oldKeyWords = targetMat.shaderKeywords;
|
||||
propertiesStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
propertiesStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
bigLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
bigLabelStyle.fontSize = bigFontSize;
|
||||
smallLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
smallLabelStyle.fontSize = smallFontSize;
|
||||
toggleButtonStyle = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleCenter, richText = true };
|
||||
currEnabledDrawers = new bool[materialDrawers.Length];
|
||||
bool isShaderSRP = IsSRPShader();
|
||||
|
||||
uint iniDrawers = (uint)ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue;
|
||||
for(int i = 0; i < materialDrawers.Length; i++) currEnabledDrawers[i] = (materialDrawers[i] & iniDrawers) > 0;
|
||||
|
||||
GUILayout.Label("General Properties", bigLabelStyle);
|
||||
DrawProperty(0);
|
||||
if (isShaderSRP)
|
||||
{
|
||||
DrawProperty(172);
|
||||
}
|
||||
|
||||
DrawProperty(1);
|
||||
DrawProperty(2);
|
||||
|
||||
|
||||
currEnabledDrawers[advancedConfigDrawer] = GUILayout.Toggle(currEnabledDrawers[advancedConfigDrawer], new GUIContent("<size=12>Show Advanced Configuration</size>"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[advancedConfigDrawer])
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
Blending();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
Culling();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ZTest();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ZWrite();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GenericEffect("Unity Fog", "FOG_ON", -1, -1, false, boldToggleLetters: false);
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
Billboard("Billboard active", "BILBOARD_ON");
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
SpriteAtlas("Sprite inside an atlas?", "ATLAS_ON");
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.EnableInstancingField();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.RenderQueueField();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("Color Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[colorFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[colorFxShapeDrawer], new GUIContent("Show Color Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[colorFxShapeDrawer])
|
||||
{
|
||||
Glow("Glow", "GLOW_ON");
|
||||
if (isShaderSRP)
|
||||
{
|
||||
GenericEffect("Fade", "FADE_ON", 7, 13, true, null, new int[] { 173, 174 });
|
||||
}
|
||||
else
|
||||
{
|
||||
GenericEffect("Fade", "FADE_ON", 7, 13, true);
|
||||
}
|
||||
|
||||
Outline("Outline", "OUTBASE_ON", isShaderSRP);
|
||||
GenericEffect("Alpha Outline", "ALPHAOUTLINE_ON", 26, 30, true, "A more performant but less flexible outline");
|
||||
InnerOutline("Inner Outline", "INNEROUTLINE_ON", 66, 69);
|
||||
Gradient("Gradient & Radial Gradient", "GRADIENT_ON");
|
||||
GenericEffect("Color Swap", "COLORSWAP_ON", 36, 42, true, "You will need a mask texture (see Documentation)", new int[] { 154 });
|
||||
GenericEffect("Hue Shift", "HSV_ON", 43, 45);
|
||||
ColorChange("Change 1 Color", "CHANGECOLOR_ON");
|
||||
ColorRamp("Color Ramp", "COLORRAMP_ON");
|
||||
GenericEffect("Hit Effect", "HITEFFECT_ON", 46, 48);
|
||||
GenericEffect("Negative", "NEGATIVE_ON", 49, 49);
|
||||
GenericEffect("Pixelate", "PIXELATE_ON", 50, 50, true, "Looks bad with distorition effects");
|
||||
GreyScale("GreyScale", "GREYSCALE_ON");
|
||||
Posterize("Posterize", "POSTERIZE_ON");
|
||||
Blur("Blur", "BLUR_ON");
|
||||
GenericEffect("Motion Blur", "MOTIONBLUR_ON", 62, 63);
|
||||
GenericEffect("Ghost", "GHOST_ON", 64, 65, true, "This effect will not affect the outline", new int[] { 157 });
|
||||
GenericEffect("Hologram", "HOLOGRAM_ON", 73, 77, true, null, new int[] { 140, 158 });
|
||||
GenericEffect("Chromatic Aberration", "CHROMABERR_ON", 78, 79);
|
||||
if(!isShaderSRP) GenericEffect("Glitch", "GLITCH_ON", 80, 80, true, null, new int[] { 139, 172 });
|
||||
else GenericEffect("Glitch", "GLITCH_ON", 80, 80, true, null, new int[] { 139, 179 });
|
||||
GenericEffect("Flicker", "FLICKER_ON", 81, 83);
|
||||
GenericEffect("Shadow", "SHADOW_ON", 84, 87);
|
||||
GenericEffect("Shine", "SHINE_ON", 133, 138);
|
||||
GenericEffect("Contrast & Brightness", "CONTRAST_ON", 152, 153);
|
||||
Overlay("Overlay Texture", "OVERLAY_ON", isShaderSRP);
|
||||
GenericEffect("Alpha Cutoff", "ALPHACUTOFF_ON", 70, 70);
|
||||
GenericEffect("Alpha Round", "ALPHAROUND_ON", 144, 144);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("UV Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[uvFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[uvFxShapeDrawer], new GUIContent("Show UV Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[uvFxShapeDrawer])
|
||||
{
|
||||
GenericEffect("Hand Drawn", "DOODLE_ON", 88, 89);
|
||||
Grass("Grass Movement / Wind", "WIND_ON");
|
||||
GenericEffect("Wave", "WAVEUV_ON", 94, 98);
|
||||
GenericEffect("Round Wave", "ROUNDWAVEUV_ON", 127, 128);
|
||||
GenericEffect("Rect Size (Enable wireframe to see result)", "RECTSIZE_ON", 99, 99, true, "Only on single sprites spritesheets NOT supported");
|
||||
GenericEffect("Offset", "OFFSETUV_ON", 100, 101);
|
||||
GenericEffect("Clipping / Fill Amount", "CLIPPING_ON", 102, 105);
|
||||
GenericEffect("Radial Clipping / Radial Fill", "RADIALCLIPPING_ON", 164, 166);
|
||||
GenericEffect("Texture Scroll", "TEXTURESCROLL_ON", 106, 107, true, "Set Texture Wrap Mode to Repeat");
|
||||
GenericEffect("Zoom", "ZOOMUV_ON", 108, 108);
|
||||
if (isShaderSRP)
|
||||
{
|
||||
GenericEffect("Distortion", "DISTORT_ON", 109, 112, true, null, new int[] { 177 });
|
||||
}
|
||||
else
|
||||
{
|
||||
GenericEffect("Distortion", "DISTORT_ON", 109, 112);
|
||||
}
|
||||
|
||||
GenericEffect("Warp Distortion", "WARP_ON", 167, 169);
|
||||
GenericEffect("Twist", "TWISTUV_ON", 113, 116);
|
||||
GenericEffect("Rotate", "ROTATEUV_ON", 117, 117, true, "_Tip_ Use Clipping effect to avoid possible undesired parts");
|
||||
GenericEffect("Polar Coordinates (Tile texture for good results)", "POLARUV_ON", -1, -1);
|
||||
GenericEffect("Fish Eye", "FISHEYE_ON", 118, 118);
|
||||
GenericEffect("Pinch", "PINCH_ON", 119, 119);
|
||||
GenericEffect("Shake", "SHAKEUV_ON", 120, 122);
|
||||
}
|
||||
|
||||
SetAndSaveEnabledDrawers(iniDrawers);
|
||||
}
|
||||
|
||||
private void SetAndSaveEnabledDrawers(uint iniDrawers)
|
||||
{
|
||||
uint currDrawers = 0;
|
||||
for(int i = 0; i < currEnabledDrawers.Length; i++)
|
||||
{
|
||||
if(currEnabledDrawers[i]) currDrawers |= materialDrawers[i];
|
||||
}
|
||||
|
||||
if(iniDrawers != currDrawers) ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue = currDrawers;
|
||||
}
|
||||
|
||||
private void Blending()
|
||||
{
|
||||
MaterialProperty srcM = ShaderGUI.FindProperty("_MySrcMode", matProperties);
|
||||
MaterialProperty dstM = ShaderGUI.FindProperty("_MyDstMode", matProperties);
|
||||
if(srcM.floatValue == 0 && dstM.floatValue == 0)
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
}
|
||||
|
||||
GUILayout.Label("Look for 'ShaderLab: Blending' if you don't know what this is", smallLabelStyle);
|
||||
if(GUILayout.Button("Back To Default Blending"))
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
srcMode = (BlendMode)srcM.floatValue;
|
||||
dstMode = (BlendMode)dstM.floatValue;
|
||||
srcMode = (BlendMode)EditorGUILayout.EnumPopup("SrcMode", srcMode);
|
||||
dstMode = (BlendMode)EditorGUILayout.EnumPopup("DstMode", dstMode);
|
||||
srcM.floatValue = (float)(srcMode);
|
||||
dstM.floatValue = (float)(dstMode);
|
||||
|
||||
bool ini = oldKeyWords.Contains("PREMULTIPLYALPHA_ON");
|
||||
bool toggle = EditorGUILayout.Toggle("Premultiply Alpha?", ini);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle) targetMat.EnableKeyword("PREMULTIPLYALPHA_ON");
|
||||
else targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
private void Billboard(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = inspector;
|
||||
toggle = GUILayout.Toggle(toggle, effectNameLabel);
|
||||
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
GUILayout.Label("Don't use this feature on UI elements!", smallLabelStyle);
|
||||
DrawProperty(129, true);
|
||||
MaterialProperty billboardY = matProperties[129];
|
||||
if(billboardY.floatValue == 1) targetMat.EnableKeyword("BILBOARDY_ON");
|
||||
else targetMat.DisableKeyword("BILBOARDY_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
private void ZWrite()
|
||||
{
|
||||
MaterialProperty zWrite = ShaderGUI.FindProperty("_ZWrite", matProperties);
|
||||
bool toggle = zWrite.floatValue > 0.9f ? true : false;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
float tempValue = zWrite.floatValue;
|
||||
toggle = GUILayout.Toggle(toggle, new GUIContent("Enable Z Write"));
|
||||
if(toggle) zWrite.floatValue = 1.0f;
|
||||
else zWrite.floatValue = 0.0f;
|
||||
if(tempValue != zWrite.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void ZTest()
|
||||
{
|
||||
MaterialProperty zTestM = ShaderGUI.FindProperty("_ZTestMode", matProperties);
|
||||
float tempValue = zTestM.floatValue;
|
||||
zTestMode = (UnityEngine.Rendering.CompareFunction)zTestM.floatValue;
|
||||
zTestMode = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("Z TestMode", zTestMode);
|
||||
zTestM.floatValue = (float)(zTestMode);
|
||||
if(tempValue != zTestM.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
|
||||
private void Culling()
|
||||
{
|
||||
MaterialProperty cullO = ShaderGUI.FindProperty("_CullingOption", matProperties);;
|
||||
float tempValue = cullO.floatValue;
|
||||
cullMode = (UnityEngine.Rendering.CullMode)cullO.floatValue;
|
||||
cullMode = (UnityEngine.Rendering.CullMode)EditorGUILayout.EnumPopup("Culling Mode", cullMode);
|
||||
cullO.floatValue = (float)(cullMode);
|
||||
if(tempValue != cullO.floatValue && !Application.isPlaying) Save();
|
||||
}
|
||||
|
||||
private void SpriteAtlas(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
toggle = GUILayout.Toggle(toggle, inspector);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("Make sure SpriteAtlasUV component is added \n " +
|
||||
"*Check documentation if unsure what this does or how it works", smallLabelStyle);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
private void Outline(string inspector, string keyword, bool isSRPShader)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + ".Outline";
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("OUTBASE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(14);
|
||||
DrawProperty(15);
|
||||
DrawProperty(16);
|
||||
DrawEffectSubKeywordToggle("Outline High Resolution?", "OUTBASE8DIR_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlinePixelPerf = DrawEffectSubKeywordToggle("Outline is Pixel Perfect?", "OUTBASEPIXELPERF_ON");
|
||||
if(outlinePixelPerf) DrawProperty(18);
|
||||
else DrawProperty(17);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineTexture = DrawEffectSubKeywordToggle("Outline uses texture?", "OUTTEX_ON");
|
||||
if(outlineTexture)
|
||||
{
|
||||
DrawProperty(19);
|
||||
DrawProperty(20);
|
||||
DrawProperty(21);
|
||||
|
||||
if (isSRPShader)
|
||||
{
|
||||
DrawProperty(175);
|
||||
}
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineDistort = DrawEffectSubKeywordToggle("Outline uses distortion?", "OUTDIST_ON");
|
||||
if(outlineDistort)
|
||||
{
|
||||
DrawProperty(22);
|
||||
DrawProperty(23);
|
||||
DrawProperty(24);
|
||||
DrawProperty(25);
|
||||
|
||||
if (isSRPShader)
|
||||
{
|
||||
DrawProperty(176);
|
||||
}
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
DrawEffectSubKeywordToggle("Only render outline?", "ONLYOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("OUTBASE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GenericEffect(string inspector, string keyword, int first, int last, bool effectCounter = true, string preMessage = null, int[] extraProperties = null, bool boldToggleLetters = true)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
if(effectCounter)
|
||||
{
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
effectCount++;
|
||||
}
|
||||
else effectNameLabel.text = inspector;
|
||||
if(boldToggleLetters) toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
else toggle = GUILayout.Toggle(toggle, effectNameLabel);
|
||||
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
if(preMessage != null) GUILayout.Label(preMessage, smallLabelStyle);
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
if(extraProperties != null)
|
||||
foreach(int i in extraProperties)
|
||||
DrawProperty(i);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
if(boldToggleLetters) EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Glow(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GLOW_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useGlowTex = DrawEffectSubKeywordToggle("Use Glow Texture?", "GLOWTEX_ON");
|
||||
if(useGlowTex) DrawProperty(6);
|
||||
|
||||
DrawProperty(3);
|
||||
DrawProperty(4);
|
||||
DrawProperty(5, true);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GLOW_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorRamp(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("COLORRAMP_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useEditableGradient = false;
|
||||
if(AssetDatabase.Contains(targetMat))
|
||||
{
|
||||
useEditableGradient = oldKeyWords.Contains("GRADIENTCOLORRAMP_ON");
|
||||
bool gradientTex = useEditableGradient;
|
||||
gradientTex = GUILayout.Toggle(gradientTex, new GUIContent("Use Editable Gradient?"));
|
||||
if(useEditableGradient != gradientTex)
|
||||
{
|
||||
Save();
|
||||
if(gradientTex)
|
||||
{
|
||||
useEditableGradient = true;
|
||||
targetMat.EnableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
|
||||
if(useEditableGradient) matEditor.ShaderProperty(matProperties[159], matProperties[159].displayName);
|
||||
}
|
||||
else GUILayout.Label("*Save to folder to allow for dynamic Gradient property", smallLabelStyle);
|
||||
|
||||
if(!useEditableGradient) DrawProperty(51);
|
||||
|
||||
DrawProperty(52);
|
||||
DrawProperty(53, true);
|
||||
MaterialProperty colorRampOut = matProperties[53];
|
||||
if(colorRampOut.floatValue == 1) targetMat.EnableKeyword("COLORRAMPOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("COLORRAMPOUTLINE_ON");
|
||||
DrawProperty(155);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("COLORRAMP_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorChange(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = 123; i < 127; i++) DrawProperty(i);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR2_ON");
|
||||
bool toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 2", ini);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR2_ON");
|
||||
for(int i = 146; i < 149; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR2_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR3_ON");
|
||||
toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 3", toggle2);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR3_ON");
|
||||
for(int i = 149; i < 152; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR3_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GreyScale(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GREYSCALE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(54);
|
||||
DrawProperty(56);
|
||||
DrawProperty(55, true);
|
||||
MaterialProperty greyScaleOut = matProperties[55];
|
||||
if(greyScaleOut.floatValue == 1) targetMat.EnableKeyword("GREYSCALEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("GREYSCALEOUTLINE_ON");
|
||||
DrawProperty(156);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GREYSCALE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Posterize(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("POSTERIZE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(57);
|
||||
DrawProperty(58);
|
||||
DrawProperty(59, true);
|
||||
MaterialProperty posterizeOut = matProperties[59];
|
||||
if(posterizeOut.floatValue == 1) targetMat.EnableKeyword("POSTERIZEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("POSTERIZEOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("POSTERIZE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Blur(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("BLUR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("This effect will not affect the outline", smallLabelStyle);
|
||||
DrawProperty(60);
|
||||
DrawProperty(61, true);
|
||||
MaterialProperty blurIsHd = matProperties[61];
|
||||
if(blurIsHd.floatValue == 1) targetMat.EnableKeyword("BLURISHD_ON");
|
||||
else targetMat.DisableKeyword("BLURISHD_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("BLUR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Grass(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("WIND_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(90);
|
||||
DrawProperty(91);
|
||||
DrawProperty(145);
|
||||
DrawProperty(92);
|
||||
DrawProperty(93, true);
|
||||
MaterialProperty grassManual = matProperties[92];
|
||||
if(grassManual.floatValue == 1) targetMat.EnableKeyword("MANUALWIND_ON");
|
||||
else targetMat.DisableKeyword("MANUALWIND_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("WIND_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void InnerOutline(string inspector, string keyword, int first, int last)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawProperty(72, true);
|
||||
MaterialProperty onlyInOutline = matProperties[72];
|
||||
if(onlyInOutline.floatValue == 1) targetMat.EnableKeyword("ONLYINNEROUTLINE_ON");
|
||||
else targetMat.DisableKeyword("ONLYINNEROUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Gradient(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(143, true);
|
||||
MaterialProperty gradIsRadial = matProperties[143];
|
||||
if(gradIsRadial.floatValue == 1)
|
||||
{
|
||||
targetMat.EnableKeyword("RADIALGRADIENT_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
DrawProperty(34);
|
||||
DrawProperty(141);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetMat.DisableKeyword("RADIALGRADIENT_ON");
|
||||
bool simpleGradient = oldKeyWords.Contains("GRADIENT2COL_ON");
|
||||
bool simpleGradToggle = EditorGUILayout.Toggle("2 Color Gradient?", simpleGradient);
|
||||
if(simpleGradient && !simpleGradToggle) targetMat.DisableKeyword("GRADIENT2COL_ON");
|
||||
else if(!simpleGradient && simpleGradToggle) targetMat.EnableKeyword("GRADIENT2COL_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
if(!simpleGradToggle) DrawProperty(33);
|
||||
DrawProperty(34);
|
||||
if(!simpleGradToggle) DrawProperty(35);
|
||||
if(!simpleGradToggle) DrawProperty(141);
|
||||
DrawProperty(142);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Overlay(string inspector, string keyword, bool isShaderSRP)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool multModeOn = oldKeyWords.Contains("OVERLAYMULT_ON");
|
||||
bool isMultMode = multModeOn;
|
||||
isMultMode = GUILayout.Toggle(isMultMode, new GUIContent("Is overlay multiplicative?"));
|
||||
if(multModeOn != isMultMode)
|
||||
{
|
||||
Save();
|
||||
if(isMultMode)
|
||||
{
|
||||
multModeOn = true;
|
||||
targetMat.EnableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
|
||||
if(multModeOn) GUILayout.Label("Overlay is set to multiplicative mode", smallLabelStyle);
|
||||
else GUILayout.Label("Overlay is set to additive mode", smallLabelStyle);
|
||||
|
||||
for(int i = 160; i <= 163; i++) DrawProperty(i);
|
||||
for(int i = 170; i <= 171; i++) DrawProperty(i);
|
||||
|
||||
if (isShaderSRP)
|
||||
{
|
||||
DrawProperty(178);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void DrawProperty(int index, bool noReset = false)
|
||||
{
|
||||
MaterialProperty targetProperty = matProperties[index];
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = targetProperty.displayName;
|
||||
propertyLabel.tooltip = targetProperty.name + " (C#)";
|
||||
|
||||
matEditor.ShaderProperty(targetProperty, propertyLabel);
|
||||
|
||||
if(!noReset)
|
||||
{
|
||||
GUIContent resetButtonLabel = new GUIContent();
|
||||
resetButtonLabel.text = "R";
|
||||
resetButtonLabel.tooltip = "Resets to default value";
|
||||
if(GUILayout.Button(resetButtonLabel, GUILayout.Width(20))) ResetProperty(targetProperty);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void ResetProperty(MaterialProperty targetProperty)
|
||||
{
|
||||
AllIn1ShaderPropertyType shaderProperty = EditorUtils.GetShaderTypeByMaterialProperty(targetProperty);
|
||||
|
||||
if(originalMaterialCopy == null) originalMaterialCopy = new Material(targetMat.shader);
|
||||
if(shaderProperty == AllIn1ShaderPropertyType.Float || shaderProperty == AllIn1ShaderPropertyType.Range)
|
||||
{
|
||||
targetProperty.floatValue = originalMaterialCopy.GetFloat(targetProperty.name);
|
||||
}
|
||||
else if(shaderProperty == AllIn1ShaderPropertyType.Vector)
|
||||
{
|
||||
targetProperty.vectorValue = originalMaterialCopy.GetVector(targetProperty.name);
|
||||
}
|
||||
else if(shaderProperty == AllIn1ShaderPropertyType.Color)
|
||||
{
|
||||
targetProperty.colorValue = originalMaterialCopy.GetColor(targetProperty.name);
|
||||
}
|
||||
else if(shaderProperty == AllIn1ShaderPropertyType.Texture)
|
||||
{
|
||||
targetProperty.textureValue = originalMaterialCopy.GetTexture(targetProperty.name);
|
||||
}
|
||||
}
|
||||
|
||||
private bool DrawEffectSubKeywordToggle(string inspector, string keyword, bool setCustomConfigAfter = false)
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = inspector;
|
||||
propertyLabel.tooltip = keyword + " (C#)";
|
||||
|
||||
bool ini = oldKeyWords.Contains(keyword);
|
||||
bool toggle = ini;
|
||||
toggle = GUILayout.Toggle(toggle, propertyLabel);
|
||||
if(ini != toggle)
|
||||
{
|
||||
if(toggle) targetMat.EnableKeyword(keyword);
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
return toggle;
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
if(!Application.isPlaying) EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
EditorUtility.SetDirty(targetMat);
|
||||
}
|
||||
|
||||
private void DrawLine(Color color, int thickness = 2, int padding = 10)
|
||||
{
|
||||
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
|
||||
r.height = thickness;
|
||||
r.y += (padding / 2);
|
||||
r.x -= 2;
|
||||
r.width += 6;
|
||||
EditorGUI.DrawRect(r, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f42211545c188ae41b1e35cc1ce38187
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1SpriteShaderMaterialInspector.cs
|
||||
uploadId: 857600
|
||||
+764
@@ -0,0 +1,764 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Linq;
|
||||
using AllIn1SpriteShader;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
public class AllIn1SpriteShaderUiMaskMaterialInspector : ShaderGUI
|
||||
{
|
||||
private Material targetMat;
|
||||
private BlendMode srcMode, dstMode;
|
||||
|
||||
private GUIStyle propertiesStyle, bigLabelStyle, smallLabelStyle, toggleButtonStyle;
|
||||
private const int bigFontSize = 16, smallFontSize = 11;
|
||||
private string[] oldKeyWords;
|
||||
private int effectCount = 1;
|
||||
private Material originalMaterialCopy;
|
||||
private MaterialEditor matEditor;
|
||||
private MaterialProperty[] matProperties;
|
||||
private uint[] materialDrawers = new uint[] { 1, 2, 4 };
|
||||
bool[] currEnabledDrawers;
|
||||
private const uint advancedConfigDrawer = 0;
|
||||
private const uint colorFxShapeDrawer = 1;
|
||||
private const uint uvFxShapeDrawer = 2;
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
matEditor = materialEditor;
|
||||
matProperties = properties;
|
||||
targetMat = materialEditor.target as Material;
|
||||
effectCount = 1;
|
||||
oldKeyWords = targetMat.shaderKeywords;
|
||||
propertiesStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
propertiesStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
bigLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
bigLabelStyle.fontSize = bigFontSize;
|
||||
smallLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
smallLabelStyle.fontSize = smallFontSize;
|
||||
toggleButtonStyle = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleCenter, richText = true };
|
||||
currEnabledDrawers = new bool[materialDrawers.Length];
|
||||
uint iniDrawers = (uint)ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue;
|
||||
for(int i = 0; i < materialDrawers.Length; i++) currEnabledDrawers[i] = (materialDrawers[i] & iniDrawers) > 0;
|
||||
|
||||
GUILayout.Label("General Properties", bigLabelStyle);
|
||||
DrawProperty(0);
|
||||
DrawProperty(1);
|
||||
DrawProperty(2);
|
||||
|
||||
|
||||
currEnabledDrawers[advancedConfigDrawer] = GUILayout.Toggle(currEnabledDrawers[advancedConfigDrawer], new GUIContent("<size=12>Show Advanced Configuration</size>"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[advancedConfigDrawer])
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
Blending();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
SpriteAtlas("Sprite inside an atlas?", "ATLAS_ON");
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.EnableInstancingField();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
materialEditor.RenderQueueField();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("Color Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[colorFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[colorFxShapeDrawer], new GUIContent("Show Color Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[colorFxShapeDrawer])
|
||||
{
|
||||
Glow("Glow", "GLOW_ON");
|
||||
GenericEffect("Fade", "FADE_ON", 7, 13);
|
||||
Outline("Outline", "OUTBASE_ON");
|
||||
GenericEffect("Alpha Outline", "ALPHAOUTLINE_ON", 26, 30, true, "A more performant but less flexible outline");
|
||||
InnerOutline("Inner Outline", "INNEROUTLINE_ON", 66, 69);
|
||||
Gradient("Gradient & Radial Gradient", "GRADIENT_ON");
|
||||
GenericEffect("Color Swap", "COLORSWAP_ON", 36, 42, true, "You will need a mask texture (see Documentation)", new int[] { 154 });
|
||||
GenericEffect("Hue Shift", "HSV_ON", 43, 45);
|
||||
ColorChange("Change 1 Color", "CHANGECOLOR_ON");
|
||||
ColorRamp("Color Ramp", "COLORRAMP_ON");
|
||||
GenericEffect("Hit Effect", "HITEFFECT_ON", 46, 48);
|
||||
GenericEffect("Negative", "NEGATIVE_ON", 49, 49);
|
||||
GenericEffect("Pixelate", "PIXELATE_ON", 50, 50, true, "Looks bad with distorition effects");
|
||||
GreyScale("GreyScale", "GREYSCALE_ON");
|
||||
Posterize("Posterize", "POSTERIZE_ON");
|
||||
Blur("Blur", "BLUR_ON");
|
||||
GenericEffect("Motion Blur", "MOTIONBLUR_ON", 62, 63);
|
||||
GenericEffect("Ghost", "GHOST_ON", 64, 65, true, "This effect will not affect the outline", new int[] { 157 });
|
||||
GenericEffect("Hologram", "HOLOGRAM_ON", 73, 77, true, null, new int[] { 140, 158 });
|
||||
GenericEffect("Chromatic Aberration", "CHROMABERR_ON", 78, 79);
|
||||
GenericEffect("Glitch", "GLITCH_ON", 80, 80, true, null, new int[] { 139, 172 });
|
||||
GenericEffect("Flicker", "FLICKER_ON", 81, 83);
|
||||
GenericEffect("Shadow", "SHADOW_ON", 84, 87);
|
||||
GenericEffect("Shine", "SHINE_ON", 133, 138);
|
||||
GenericEffect("Contrast & Brightness", "CONTRAST_ON", 152, 153);
|
||||
Overlay("Overlay Texture", "OVERLAY_ON");
|
||||
GenericEffect("Alpha Cutoff", "ALPHACUTOFF_ON", 70, 70);
|
||||
GenericEffect("Alpha Round", "ALPHAROUND_ON", 144, 144);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label("UV Effects", bigLabelStyle);
|
||||
|
||||
currEnabledDrawers[uvFxShapeDrawer] = GUILayout.Toggle(currEnabledDrawers[uvFxShapeDrawer], new GUIContent("Show Alpha Effects"), toggleButtonStyle);
|
||||
if(currEnabledDrawers[uvFxShapeDrawer])
|
||||
{
|
||||
GenericEffect("Hand Drawn", "DOODLE_ON", 88, 89);
|
||||
Grass("Grass Movement / Wind", "WIND_ON");
|
||||
GenericEffect("Wave", "WAVEUV_ON", 94, 98);
|
||||
GenericEffect("Round Wave", "ROUNDWAVEUV_ON", 127, 128);
|
||||
GenericEffect("Rect Size (Enable wireframe to see result)", "RECTSIZE_ON", 99, 99, true, "Only on single sprites spritesheets NOT supported");
|
||||
GenericEffect("Offset", "OFFSETUV_ON", 100, 101);
|
||||
GenericEffect("Clipping / Fill Amount", "CLIPPING_ON", 102, 105);
|
||||
GenericEffect("Radial Clipping / Radial Fill", "RADIALCLIPPING_ON", 164, 166);
|
||||
GenericEffect("Texture Scroll", "TEXTURESCROLL_ON", 106, 107, true, "Set Texture Wrap Mode to Repeat");
|
||||
GenericEffect("Zoom", "ZOOMUV_ON", 108, 108);
|
||||
GenericEffect("Distortion", "DISTORT_ON", 109, 112);
|
||||
GenericEffect("Warp Distortion", "WARP_ON", 167, 169);
|
||||
GenericEffect("Twist", "TWISTUV_ON", 113, 116);
|
||||
GenericEffect("Rotate", "ROTATEUV_ON", 117, 117, true, "_Tip_ Use Clipping effect to avoid possible undesired parts");
|
||||
GenericEffect("Polar Coordinates (Tile texture for good results)", "POLARUV_ON", -1, -1);
|
||||
GenericEffect("Fish Eye", "FISHEYE_ON", 118, 118);
|
||||
GenericEffect("Pinch", "PINCH_ON", 119, 119);
|
||||
GenericEffect("Shake", "SHAKEUV_ON", 120, 122);
|
||||
}
|
||||
|
||||
SetAndSaveEnabledDrawers(iniDrawers);
|
||||
}
|
||||
|
||||
private void SetAndSaveEnabledDrawers(uint iniDrawers)
|
||||
{
|
||||
uint currDrawers = 0;
|
||||
for(int i = 0; i < currEnabledDrawers.Length; i++)
|
||||
{
|
||||
if(currEnabledDrawers[i]) currDrawers |= materialDrawers[i];
|
||||
}
|
||||
|
||||
if(iniDrawers != currDrawers) ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue = currDrawers;
|
||||
}
|
||||
|
||||
private void Blending()
|
||||
{
|
||||
MaterialProperty srcM = ShaderGUI.FindProperty("_MySrcMode", matProperties);
|
||||
MaterialProperty dstM = ShaderGUI.FindProperty("_MyDstMode", matProperties);
|
||||
if(srcM.floatValue == 0 && dstM.floatValue == 0)
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
}
|
||||
|
||||
GUILayout.Label("Look for 'ShaderLab: Blending' if you don't know what this is", smallLabelStyle);
|
||||
if(GUILayout.Button("Back To Default Blending"))
|
||||
{
|
||||
srcM.floatValue = 5;
|
||||
dstM.floatValue = 10;
|
||||
targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
srcMode = (BlendMode)srcM.floatValue;
|
||||
dstMode = (BlendMode)dstM.floatValue;
|
||||
srcMode = (BlendMode)EditorGUILayout.EnumPopup("SrcMode", srcMode);
|
||||
dstMode = (BlendMode)EditorGUILayout.EnumPopup("DstMode", dstMode);
|
||||
srcM.floatValue = (float)(srcMode);
|
||||
dstM.floatValue = (float)(dstMode);
|
||||
|
||||
bool ini = oldKeyWords.Contains("PREMULTIPLYALPHA_ON");
|
||||
bool toggle = EditorGUILayout.Toggle("Premultiply Alpha?", ini);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle) targetMat.EnableKeyword("PREMULTIPLYALPHA_ON");
|
||||
else targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
|
||||
}
|
||||
|
||||
private void SpriteAtlas(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
toggle = GUILayout.Toggle(toggle, inspector);
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("Make sure SpriteAtlasUV component is added \n " +
|
||||
"*Check documentation if unsure what this does or how it works", smallLabelStyle);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
private void Outline(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + ".Outline";
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("OUTBASE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(14);
|
||||
DrawProperty(15);
|
||||
DrawProperty(16);
|
||||
DrawEffectSubKeywordToggle("Outline High Resolution?", "OUTBASE8DIR_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlinePixelPerf = DrawEffectSubKeywordToggle("Outline is Pixel Perfect?", "OUTBASEPIXELPERF_ON");
|
||||
if(outlinePixelPerf) DrawProperty(18);
|
||||
else DrawProperty(17);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineTexture = DrawEffectSubKeywordToggle("Outline uses texture?", "OUTTEX_ON");
|
||||
if(outlineTexture)
|
||||
{
|
||||
DrawProperty(19);
|
||||
DrawProperty(20);
|
||||
DrawProperty(21);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
bool outlineDistort = DrawEffectSubKeywordToggle("Outline uses distortion?", "OUTDIST_ON");
|
||||
if(outlineDistort)
|
||||
{
|
||||
DrawProperty(22);
|
||||
DrawProperty(23);
|
||||
DrawProperty(24);
|
||||
DrawProperty(25);
|
||||
}
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
DrawEffectSubKeywordToggle("Only render outline?", "ONLYOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("OUTBASE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GenericEffect(string inspector, string keyword, int first, int last, bool effectCounter = true, string preMessage = null, int[] extraProperties = null, bool boldToggleLetters = true)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
if(effectCounter)
|
||||
{
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
effectCount++;
|
||||
}
|
||||
else effectNameLabel.text = inspector;
|
||||
if(boldToggleLetters) toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
else toggle = GUILayout.Toggle(toggle, effectNameLabel);
|
||||
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
if(preMessage != null) GUILayout.Label(preMessage, smallLabelStyle);
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
if(extraProperties != null)
|
||||
foreach(int i in extraProperties)
|
||||
DrawProperty(i);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
if(boldToggleLetters) EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Glow(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GLOW_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useGlowTex = DrawEffectSubKeywordToggle("Use Glow Texture?", "GLOWTEX_ON");
|
||||
if(useGlowTex) DrawProperty(6);
|
||||
|
||||
DrawProperty(3);
|
||||
DrawProperty(4);
|
||||
DrawProperty(5, true);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GLOW_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorRamp(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("COLORRAMP_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool useEditableGradient = false;
|
||||
if(AssetDatabase.Contains(targetMat))
|
||||
{
|
||||
useEditableGradient = oldKeyWords.Contains("GRADIENTCOLORRAMP_ON");
|
||||
bool gradientTex = useEditableGradient;
|
||||
gradientTex = GUILayout.Toggle(gradientTex, new GUIContent("Use Editable Gradient?"));
|
||||
if(useEditableGradient != gradientTex)
|
||||
{
|
||||
Save();
|
||||
if(gradientTex)
|
||||
{
|
||||
useEditableGradient = true;
|
||||
targetMat.EnableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("GRADIENTCOLORRAMP_ON");
|
||||
}
|
||||
|
||||
if(useEditableGradient) matEditor.ShaderProperty(matProperties[159], matProperties[159].displayName);
|
||||
}
|
||||
else GUILayout.Label("*Save to folder to allow for dynamic Gradient property", smallLabelStyle);
|
||||
|
||||
if(!useEditableGradient) DrawProperty(51);
|
||||
|
||||
DrawProperty(52);
|
||||
DrawProperty(53, true);
|
||||
MaterialProperty colorRampOut = matProperties[53];
|
||||
if(colorRampOut.floatValue == 1) targetMat.EnableKeyword("COLORRAMPOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("COLORRAMPOUTLINE_ON");
|
||||
DrawProperty(155);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("COLORRAMP_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void ColorChange(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = 123; i < 127; i++) DrawProperty(i);
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR2_ON");
|
||||
bool toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 2", ini);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR2_ON");
|
||||
for(int i = 146; i < 149; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR2_ON");
|
||||
|
||||
DrawLine(Color.grey, 1, 3);
|
||||
ini = oldKeyWords.Contains("CHANGECOLOR3_ON");
|
||||
toggle2 = ini;
|
||||
toggle2 = EditorGUILayout.Toggle("Use Color 3", toggle2);
|
||||
if(ini != toggle2) Save();
|
||||
if(toggle2)
|
||||
{
|
||||
targetMat.EnableKeyword("CHANGECOLOR3_ON");
|
||||
for(int i = 149; i < 152; i++) DrawProperty(i);
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR3_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("CHANGECOLOR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void GreyScale(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("GREYSCALE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(54);
|
||||
DrawProperty(56);
|
||||
DrawProperty(55, true);
|
||||
MaterialProperty greyScaleOut = matProperties[55];
|
||||
if(greyScaleOut.floatValue == 1) targetMat.EnableKeyword("GREYSCALEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("GREYSCALEOUTLINE_ON");
|
||||
DrawProperty(156);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("GREYSCALE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Posterize(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("POSTERIZE_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(57);
|
||||
DrawProperty(58);
|
||||
DrawProperty(59, true);
|
||||
MaterialProperty posterizeOut = matProperties[59];
|
||||
if(posterizeOut.floatValue == 1) targetMat.EnableKeyword("POSTERIZEOUTLINE_ON");
|
||||
else targetMat.DisableKeyword("POSTERIZEOUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("POSTERIZE_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Blur(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("BLUR_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
GUILayout.Label("This effect will not affect the outline", smallLabelStyle);
|
||||
DrawProperty(60);
|
||||
DrawProperty(61, true);
|
||||
MaterialProperty blurIsHd = matProperties[61];
|
||||
if(blurIsHd.floatValue == 1) targetMat.EnableKeyword("BLURISHD_ON");
|
||||
else targetMat.DisableKeyword("BLURISHD_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("BLUR_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Grass(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword("WIND_ON");
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(90);
|
||||
DrawProperty(91);
|
||||
DrawProperty(145);
|
||||
DrawProperty(92);
|
||||
DrawProperty(93, true);
|
||||
MaterialProperty grassManual = matProperties[92];
|
||||
if(grassManual.floatValue == 1) targetMat.EnableKeyword("MANUALWIND_ON");
|
||||
else targetMat.DisableKeyword("MANUALWIND_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword("WIND_ON");
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void InnerOutline(string inspector, string keyword, int first, int last)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
if(first > 0)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
for(int i = first; i <= last; i++) DrawProperty(i);
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
DrawProperty(72, true);
|
||||
MaterialProperty onlyInOutline = matProperties[72];
|
||||
if(onlyInOutline.floatValue == 1) targetMat.EnableKeyword("ONLYINNEROUTLINE_ON");
|
||||
else targetMat.DisableKeyword("ONLYINNEROUTLINE_ON");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Gradient(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
DrawProperty(143, true);
|
||||
MaterialProperty gradIsRadial = matProperties[143];
|
||||
if(gradIsRadial.floatValue == 1)
|
||||
{
|
||||
targetMat.EnableKeyword("RADIALGRADIENT_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
DrawProperty(34);
|
||||
DrawProperty(141);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetMat.DisableKeyword("RADIALGRADIENT_ON");
|
||||
bool simpleGradient = oldKeyWords.Contains("GRADIENT2COL_ON");
|
||||
bool simpleGradToggle = EditorGUILayout.Toggle("2 Color Gradient?", simpleGradient);
|
||||
if(simpleGradient && !simpleGradToggle) targetMat.DisableKeyword("GRADIENT2COL_ON");
|
||||
else if(!simpleGradient && simpleGradToggle) targetMat.EnableKeyword("GRADIENT2COL_ON");
|
||||
DrawProperty(31);
|
||||
DrawProperty(32);
|
||||
if(!simpleGradToggle) DrawProperty(33);
|
||||
DrawProperty(34);
|
||||
if(!simpleGradToggle) DrawProperty(35);
|
||||
if(!simpleGradToggle) DrawProperty(141);
|
||||
DrawProperty(142);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void Overlay(string inspector, string keyword)
|
||||
{
|
||||
bool toggle = oldKeyWords.Contains(keyword);
|
||||
bool ini = toggle;
|
||||
|
||||
GUIContent effectNameLabel = new GUIContent();
|
||||
effectNameLabel.tooltip = keyword + " (C#)";
|
||||
effectNameLabel.text = effectCount + "." + inspector;
|
||||
toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);
|
||||
|
||||
effectCount++;
|
||||
if(ini != toggle) Save();
|
||||
if(toggle)
|
||||
{
|
||||
targetMat.EnableKeyword(keyword);
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
{
|
||||
bool multModeOn = oldKeyWords.Contains("OVERLAYMULT_ON");
|
||||
bool isMultMode = multModeOn;
|
||||
isMultMode = GUILayout.Toggle(isMultMode, new GUIContent("Is overlay multiplicative?"));
|
||||
if(multModeOn != isMultMode)
|
||||
{
|
||||
Save();
|
||||
if(isMultMode)
|
||||
{
|
||||
multModeOn = true;
|
||||
targetMat.EnableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
else targetMat.DisableKeyword("OVERLAYMULT_ON");
|
||||
}
|
||||
|
||||
if(multModeOn) GUILayout.Label("Overlay is set to multiplicative mode", smallLabelStyle);
|
||||
else GUILayout.Label("Overlay is set to additive mode", smallLabelStyle);
|
||||
|
||||
for(int i = 160; i <= 163; i++) DrawProperty(i);
|
||||
for(int i = 170; i <= 171; i++) DrawProperty(i);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
|
||||
EditorGUILayout.EndToggleGroup();
|
||||
}
|
||||
|
||||
private void DrawProperty(int index, bool noReset = false)
|
||||
{
|
||||
MaterialProperty targetProperty = matProperties[index];
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = targetProperty.displayName;
|
||||
propertyLabel.tooltip = targetProperty.name + " (C#)";
|
||||
|
||||
matEditor.ShaderProperty(targetProperty, propertyLabel);
|
||||
|
||||
if(!noReset)
|
||||
{
|
||||
GUIContent resetButtonLabel = new GUIContent();
|
||||
resetButtonLabel.text = "R";
|
||||
resetButtonLabel.tooltip = "Resets to default value";
|
||||
if(GUILayout.Button(resetButtonLabel, GUILayout.Width(20))) ResetProperty(targetProperty);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void ResetProperty(MaterialProperty targetProperty)
|
||||
{
|
||||
AllIn1ShaderPropertyType propertyType = EditorUtils.GetShaderTypeByMaterialProperty(targetProperty);
|
||||
|
||||
if(originalMaterialCopy == null) originalMaterialCopy = new Material(targetMat.shader);
|
||||
if(propertyType == AllIn1ShaderPropertyType.Float || propertyType == AllIn1ShaderPropertyType.Range)
|
||||
{
|
||||
targetProperty.floatValue = originalMaterialCopy.GetFloat(targetProperty.name);
|
||||
}
|
||||
else if(propertyType == AllIn1ShaderPropertyType.Vector)
|
||||
{
|
||||
targetProperty.vectorValue = originalMaterialCopy.GetVector(targetProperty.name);
|
||||
}
|
||||
else if(propertyType == AllIn1ShaderPropertyType.Color)
|
||||
{
|
||||
targetProperty.colorValue = originalMaterialCopy.GetColor(targetProperty.name);
|
||||
}
|
||||
else if(propertyType == AllIn1ShaderPropertyType.Texture)
|
||||
{
|
||||
targetProperty.textureValue = originalMaterialCopy.GetTexture(targetProperty.name);
|
||||
}
|
||||
}
|
||||
|
||||
private bool DrawEffectSubKeywordToggle(string inspector, string keyword, bool setCustomConfigAfter = false)
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = inspector;
|
||||
propertyLabel.tooltip = keyword + " (C#)";
|
||||
|
||||
bool ini = oldKeyWords.Contains(keyword);
|
||||
bool toggle = ini;
|
||||
toggle = GUILayout.Toggle(toggle, propertyLabel);
|
||||
if(ini != toggle)
|
||||
{
|
||||
if(toggle) targetMat.EnableKeyword(keyword);
|
||||
else targetMat.DisableKeyword(keyword);
|
||||
}
|
||||
|
||||
return toggle;
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
if(!Application.isPlaying) EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
EditorUtility.SetDirty(targetMat);
|
||||
}
|
||||
|
||||
private void DrawLine(Color color, int thickness = 2, int padding = 10)
|
||||
{
|
||||
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
|
||||
r.height = thickness;
|
||||
r.y += (padding / 2);
|
||||
r.x -= 2;
|
||||
r.width += 6;
|
||||
EditorGUI.DrawRect(r, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcdb12210426bb34cb44a19ffb54132d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/AllIn1SpriteShaderUiMaskMaterialInspector.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string MAIN_ASSEMBLY_NAME = "AllIn1SpriteShaderAssembly.asmdef";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd7850185e6f57c4596c42efd4dccc33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/Constants.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,77 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
public static class EditorUtils
|
||||
{
|
||||
public static string UnifyEOL(string text)
|
||||
{
|
||||
if(string.IsNullOrEmpty(text)) return text;
|
||||
|
||||
text = text.Replace("\r\n", "\n");
|
||||
text = text.Replace("\r", "\n");
|
||||
return text;
|
||||
}
|
||||
|
||||
public static AllIn1ShaderPropertyType GetShaderTypeByMaterialProperty(MaterialProperty matProperty)
|
||||
{
|
||||
AllIn1ShaderPropertyType res;
|
||||
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
switch (matProperty.propertyType)
|
||||
{
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Color:
|
||||
res = AllIn1ShaderPropertyType.Color;
|
||||
break;
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Float:
|
||||
res = AllIn1ShaderPropertyType.Float;
|
||||
break;
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Int:
|
||||
res = AllIn1ShaderPropertyType.Int;
|
||||
break;
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Range:
|
||||
res = AllIn1ShaderPropertyType.Range;
|
||||
break;
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Texture:
|
||||
res = AllIn1ShaderPropertyType.Texture;
|
||||
break;
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Vector:
|
||||
res = AllIn1ShaderPropertyType.Vector;
|
||||
break;
|
||||
default:
|
||||
res = AllIn1ShaderPropertyType.Vector;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (matProperty.type)
|
||||
{
|
||||
case MaterialProperty.PropType.Color:
|
||||
res = AllIn1ShaderPropertyType.Color;
|
||||
break;
|
||||
case MaterialProperty.PropType.Float:
|
||||
res = AllIn1ShaderPropertyType.Float;
|
||||
break;
|
||||
case MaterialProperty.PropType.Int:
|
||||
res = AllIn1ShaderPropertyType.Int;
|
||||
break;
|
||||
case MaterialProperty.PropType.Range:
|
||||
res = AllIn1ShaderPropertyType.Range;
|
||||
break;
|
||||
case MaterialProperty.PropType.Texture:
|
||||
res = AllIn1ShaderPropertyType.Texture;
|
||||
break;
|
||||
case MaterialProperty.PropType.Vector:
|
||||
res = AllIn1ShaderPropertyType.Vector;
|
||||
break;
|
||||
default:
|
||||
res = AllIn1ShaderPropertyType.Vector;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44cca39610f3ac740aaa53036cfef5d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/EditorUtils.cs
|
||||
uploadId: 857600
|
||||
@@ -0,0 +1,75 @@
|
||||
//////////////////////////////////////////////////////
|
||||
// Shader Packager
|
||||
// Copyright (c) Jason Booth
|
||||
//////////////////////////////////////////////////////
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
|
||||
// Installs custom defines for render pipelines (e.g., USING_HDRP) to enable conditional compilation
|
||||
// across different pipelines. Unity doesn't provide these defines out of the box, so this helper
|
||||
// simplifies cross-pipeline compatibility.
|
||||
|
||||
namespace AllIn1SpriteShader
|
||||
{
|
||||
public static class RenderPipelineChecker
|
||||
{
|
||||
private const string HDRP_PACKAGE = "HDRenderPipelineAsset";
|
||||
private const string URP_PACKAGE = "UniversalRenderPipelineAsset";
|
||||
|
||||
public static bool IsHDRP
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
public static bool IsURP
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
public static bool IsStandardRP
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public static void RefreshData()
|
||||
{
|
||||
IsHDRP = DoesTypeExist(HDRP_PACKAGE);
|
||||
IsURP = DoesTypeExist(URP_PACKAGE);
|
||||
|
||||
if (!(IsHDRP || IsURP))
|
||||
{
|
||||
IsStandardRP = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static bool DoesTypeExist(string className)
|
||||
{
|
||||
var foundType = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
|
||||
from type in GetTypesSafe(assembly)
|
||||
where type.Name == className
|
||||
select type).FirstOrDefault();
|
||||
|
||||
return foundType != null;
|
||||
}
|
||||
|
||||
public static IEnumerable<Type> GetTypesSafe(System.Reflection.Assembly assembly)
|
||||
{
|
||||
Type[] types;
|
||||
|
||||
try
|
||||
{
|
||||
types = assembly.GetTypes();
|
||||
}
|
||||
catch (ReflectionTypeLoadException e)
|
||||
{
|
||||
types = e.Types;
|
||||
}
|
||||
|
||||
return types.Where(x => x != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83ac30b66f3fe444189a98a9bb648c51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 156513
|
||||
packageName: All In 1 Sprite Shader
|
||||
packageVersion: 4.661
|
||||
assetPath: Assets/Plugins/AllIn1SpriteShader/Scripts/Editor/RenderPipelineChecker.cs
|
||||
uploadId: 857600
|
||||
Reference in New Issue
Block a user