|
@@ -37,6 +37,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
|
|
|
protected MaterialEditor _materialEditor;
|
|
|
bool _showAdvancedOutlineSettings = false;
|
|
|
+ bool _showStencilSettings = false;
|
|
|
|
|
|
MaterialProperty _OutlineWidth = null;
|
|
|
MaterialProperty _OutlineColor = null;
|
|
@@ -45,6 +46,8 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
MaterialProperty _OutlineSmoothness = null;
|
|
|
MaterialProperty _Use8Neighbourhood = null;
|
|
|
MaterialProperty _OutlineMipLevel = null;
|
|
|
+ MaterialProperty _StencilComp = null;
|
|
|
+ MaterialProperty _StencilRef = null;
|
|
|
|
|
|
static GUIContent _EnableOutlineText = new GUIContent("Outline", "Enable outline rendering. Draws an outline by sampling 4 or 8 neighbourhood pixels at a given distance specified via 'Outline Width'.");
|
|
|
static GUIContent _OutlineWidthText = new GUIContent("Outline Width", "");
|
|
@@ -54,8 +57,11 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
static GUIContent _OutlineSmoothnessText = new GUIContent("Outline Smoothness", "");
|
|
|
static GUIContent _Use8NeighbourhoodText = new GUIContent("Sample 8 Neighbours", "");
|
|
|
static GUIContent _OutlineMipLevelText = new GUIContent("Outline Mip Level", "");
|
|
|
+ static GUIContent _StencilCompText = new GUIContent("Stencil Comparison", "");
|
|
|
+ static GUIContent _StencilRefText = new GUIContent("Stencil Reference", "");
|
|
|
|
|
|
static GUIContent _OutlineAdvancedText = new GUIContent("Advanced", "");
|
|
|
+ static GUIContent _ShowStencilText = new GUIContent("Stencil", "Stencil parameters for mask interaction.");
|
|
|
|
|
|
protected const string ShaderOutlineNamePrefix = "Spine/Outline/";
|
|
|
protected const string ShaderNormalNamePrefix = "Spine/";
|
|
@@ -68,6 +74,8 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
|
|
|
base.OnGUI(materialEditor, properties);
|
|
|
EditorGUILayout.Space();
|
|
|
+ RenderStencilProperties();
|
|
|
+ EditorGUILayout.Space();
|
|
|
RenderOutlineProperties();
|
|
|
}
|
|
|
|
|
@@ -84,6 +92,26 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
|
|
|
_OutlineSmoothness = FindProperty("_OutlineSmoothness", props, false);
|
|
|
_Use8Neighbourhood = FindProperty("_Use8Neighbourhood", props, false);
|
|
|
_OutlineMipLevel = FindProperty("_OutlineMipLevel", props, false);
|
|
|
+
|
|
|
+ _StencilComp = FindProperty("_StencilComp", props, false);
|
|
|
+ _StencilRef = FindProperty("_StencilRef", props, false);
|
|
|
+ if (_StencilRef == null)
|
|
|
+ _StencilRef = FindProperty("_Stencil", props, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected virtual void RenderStencilProperties () {
|
|
|
+ if (_StencilComp == null)
|
|
|
+ return; // not a shader supporting custom stencil operations
|
|
|
+
|
|
|
+ // Use default labelWidth
|
|
|
+ EditorGUIUtility.labelWidth = 0f;
|
|
|
+ _showStencilSettings = EditorGUILayout.Foldout(_showStencilSettings, _ShowStencilText);
|
|
|
+ if (_showStencilSettings) {
|
|
|
+ using (new SpineInspectorUtility.IndentScope()) {
|
|
|
+ _materialEditor.ShaderProperty(_StencilComp, _StencilCompText);
|
|
|
+ _materialEditor.ShaderProperty(_StencilRef, _StencilRefText);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
protected virtual void RenderOutlineProperties () {
|