[unity] Changed SpineShaderWithOutlineGUI outline methods from private to protected virtual.

This commit is contained in:
Harald Csaszar 2023-04-18 11:48:40 +02:00
parent 0289cdcb92
commit 6245c399fe
3 changed files with 5 additions and 18 deletions

View File

@ -34,6 +34,7 @@
* `SkeletonGraphic` now supports automatic scaling based on its `RectTransform` bounds. Automatic scaling can be enabled by setting the added `Layout Scale Mode` Inspector property to either `Width Controls Height`, `Height Controls Width`, `FitInParent` or `EnvelopeParent`. It is set to `None` by default to keep previous behaviour and avoid breaking existing projects. To modify the reference layout bounds, hit the additional `Edit Layout Bounds` toggle button to switch into edit mode, adjust the bounds or hit `Match RectTransform with Mesh`, and hit the button again when done adjusting. The skeleton will now be scaled accordingly to fit the reference layout bounds to the object's `RectTransform`. * `SkeletonGraphic` now supports automatic scaling based on its `RectTransform` bounds. Automatic scaling can be enabled by setting the added `Layout Scale Mode` Inspector property to either `Width Controls Height`, `Height Controls Width`, `FitInParent` or `EnvelopeParent`. It is set to `None` by default to keep previous behaviour and avoid breaking existing projects. To modify the reference layout bounds, hit the additional `Edit Layout Bounds` toggle button to switch into edit mode, adjust the bounds or hit `Match RectTransform with Mesh`, and hit the button again when done adjusting. The skeleton will now be scaled accordingly to fit the reference layout bounds to the object's `RectTransform`.
* **Breaking changes** * **Breaking changes**
* Changed `SpineShaderWithOutlineGUI` outline related methods from `private` to `protected virtual` to allow for custom shader GUI subclasses to switch to different outline shaders.
* **Changes of default values** * **Changes of default values**

View File

@ -84,7 +84,6 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
#endregion #endregion
#region Virtual Interface #region Virtual Interface
protected virtual void FindProperties (MaterialProperty[] props) { protected virtual void FindProperties (MaterialProperty[] props) {
_OutlineWidth = FindProperty("_OutlineWidth", props, false); _OutlineWidth = FindProperty("_OutlineWidth", props, false);
@ -168,11 +167,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
} }
} }
#endregion protected virtual void SwitchShaderToOutlineSettings (Material material, bool enableOutline) {
#region Private Functions
void SwitchShaderToOutlineSettings (Material material, bool enableOutline) {
string shaderName = material.shader.name; string shaderName = material.shader.name;
bool isSetToOutlineShader = shaderName.Contains(ShaderOutlineNamePrefix); bool isSetToOutlineShader = shaderName.Contains(ShaderOutlineNamePrefix);
@ -187,7 +182,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
} }
} }
static bool IsOutlineEnabled (MaterialEditor editor, out bool mixedValue) { protected static bool IsOutlineEnabled (MaterialEditor editor, out bool mixedValue) {
mixedValue = false; mixedValue = false;
bool isAnyEnabled = false; bool isAnyEnabled = false;
foreach (Material material in editor.targets) { foreach (Material material in editor.targets) {
@ -200,7 +195,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
return isAnyEnabled; return isAnyEnabled;
} }
static bool IsShaderWithoutStandardVariantShader (MaterialEditor editor, out bool mixedValue) { protected static bool IsShaderWithoutStandardVariantShader (MaterialEditor editor, out bool mixedValue) {
mixedValue = false; mixedValue = false;
bool isAnyShaderWithoutVariant = false; bool isAnyShaderWithoutVariant = false;
foreach (Material material in editor.targets) { foreach (Material material in editor.targets) {
@ -213,13 +208,12 @@ public class SpineShaderWithOutlineGUI : ShaderGUI {
return isAnyShaderWithoutVariant; return isAnyShaderWithoutVariant;
} }
static bool BoldToggleField (GUIContent label, bool value) { protected static bool BoldToggleField (GUIContent label, bool value) {
FontStyle origFontStyle = EditorStyles.label.fontStyle; FontStyle origFontStyle = EditorStyles.label.fontStyle;
EditorStyles.label.fontStyle = FontStyle.Bold; EditorStyles.label.fontStyle = FontStyle.Bold;
value = EditorGUILayout.Toggle(label, value, EditorStyles.toggle); value = EditorGUILayout.Toggle(label, value, EditorStyles.toggle);
EditorStyles.label.fontStyle = origFontStyle; EditorStyles.label.fontStyle = origFontStyle;
return value; return value;
} }
#endregion #endregion
} }

View File

@ -268,14 +268,6 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
_lightAffectsAdditive = FindProperty("_LightAffectsAdditive", props, false); _lightAffectsAdditive = FindProperty("_LightAffectsAdditive", props, false);
} }
static bool BoldToggleField (GUIContent label, bool value) {
FontStyle origFontStyle = EditorStyles.label.fontStyle;
EditorStyles.label.fontStyle = FontStyle.Bold;
value = EditorGUILayout.Toggle(label, value, EditorStyles.toggle);
EditorStyles.label.fontStyle = origFontStyle;
return value;
}
protected virtual void ShaderPropertiesGUI () { protected virtual void ShaderPropertiesGUI () {
// Use default labelWidth // Use default labelWidth
EditorGUIUtility.labelWidth = 0f; EditorGUIUtility.labelWidth = 0f;