|
@@ -65,6 +65,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
|
|
|
protected const string ShaderOutlineNamePrefix = "Spine/Outline/";
|
|
|
protected const string ShaderNormalNamePrefix = "Spine/";
|
|
|
+ protected const string ShaderWithoutStandardVariantSuffix = "OutlineOnly";
|
|
|
|
|
|
#region ShaderGUI
|
|
|
|
|
@@ -123,20 +124,30 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
EditorGUIUtility.labelWidth = 0f;
|
|
|
|
|
|
bool mixedValue;
|
|
|
- bool isOutlineEnabled = IsOutlineEnabled(_materialEditor, out mixedValue);
|
|
|
- EditorGUI.showMixedValue = mixedValue;
|
|
|
- EditorGUI.BeginChangeCheck();
|
|
|
-
|
|
|
- var origFontStyle = EditorStyles.label.fontStyle;
|
|
|
- EditorStyles.label.fontStyle = FontStyle.Bold;
|
|
|
- isOutlineEnabled = EditorGUILayout.Toggle(_EnableOutlineText, isOutlineEnabled);
|
|
|
- EditorStyles.label.fontStyle = origFontStyle;
|
|
|
- EditorGUI.showMixedValue = false;
|
|
|
- if (EditorGUI.EndChangeCheck()) {
|
|
|
- foreach (Material material in _materialEditor.targets) {
|
|
|
- SwitchShaderToOutlineSettings(material, isOutlineEnabled);
|
|
|
+ bool hasOutlineVariant = !IsShaderWithoutStandardVariantShader(_materialEditor, out mixedValue);
|
|
|
+ bool isOutlineEnabled = true;
|
|
|
+ if (hasOutlineVariant) {
|
|
|
+ isOutlineEnabled = IsOutlineEnabled(_materialEditor, out mixedValue);
|
|
|
+ EditorGUI.showMixedValue = mixedValue;
|
|
|
+ EditorGUI.BeginChangeCheck();
|
|
|
+
|
|
|
+ var origFontStyle = EditorStyles.label.fontStyle;
|
|
|
+ EditorStyles.label.fontStyle = FontStyle.Bold;
|
|
|
+ isOutlineEnabled = EditorGUILayout.Toggle(_EnableOutlineText, isOutlineEnabled);
|
|
|
+ EditorStyles.label.fontStyle = origFontStyle;
|
|
|
+ EditorGUI.showMixedValue = false;
|
|
|
+ if (EditorGUI.EndChangeCheck()) {
|
|
|
+ foreach (Material material in _materialEditor.targets) {
|
|
|
+ SwitchShaderToOutlineSettings(material, isOutlineEnabled);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ var origFontStyle = EditorStyles.label.fontStyle;
|
|
|
+ EditorStyles.label.fontStyle = FontStyle.Bold;
|
|
|
+ EditorGUILayout.LabelField(_EnableOutlineText);
|
|
|
+ EditorStyles.label.fontStyle = origFontStyle;
|
|
|
+ }
|
|
|
|
|
|
if (isOutlineEnabled) {
|
|
|
_materialEditor.ShaderProperty(_OutlineWidth, _OutlineWidthText);
|
|
@@ -162,7 +173,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
void SwitchShaderToOutlineSettings (Material material, bool enableOutline) {
|
|
|
|
|
|
var shaderName = material.shader.name;
|
|
|
- bool isSetToOutlineShader = shaderName.StartsWith(ShaderOutlineNamePrefix);
|
|
|
+ bool isSetToOutlineShader = shaderName.Contains(ShaderOutlineNamePrefix);
|
|
|
if (isSetToOutlineShader && !enableOutline) {
|
|
|
shaderName = shaderName.Replace(ShaderOutlineNamePrefix, ShaderNormalNamePrefix);
|
|
|
_materialEditor.SetShader(Shader.Find(shaderName), false);
|
|
@@ -179,7 +190,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
mixedValue = false;
|
|
|
bool isAnyEnabled = false;
|
|
|
foreach (Material material in editor.targets) {
|
|
|
- if (material.shader.name.StartsWith(ShaderOutlineNamePrefix)) {
|
|
|
+ if (material.shader.name.Contains(ShaderOutlineNamePrefix)) {
|
|
|
isAnyEnabled = true;
|
|
|
}
|
|
|
else if (isAnyEnabled) {
|
|
@@ -189,6 +200,20 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
return isAnyEnabled;
|
|
|
}
|
|
|
|
|
|
+ static bool IsShaderWithoutStandardVariantShader (MaterialEditor editor, out bool mixedValue) {
|
|
|
+ mixedValue = false;
|
|
|
+ bool isAnyShaderWithoutVariant = false;
|
|
|
+ foreach (Material material in editor.targets) {
|
|
|
+ if (material.shader.name.Contains(ShaderWithoutStandardVariantSuffix)) {
|
|
|
+ isAnyShaderWithoutVariant = true;
|
|
|
+ }
|
|
|
+ else if (isAnyShaderWithoutVariant) {
|
|
|
+ mixedValue = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return isAnyShaderWithoutVariant;
|
|
|
+ }
|
|
|
+
|
|
|
static bool BoldToggleField (GUIContent label, bool value) {
|
|
|
FontStyle origFontStyle = EditorStyles.label.fontStyle;
|
|
|
EditorStyles.label.fontStyle = FontStyle.Bold;
|