From e04f55bdb51cea04870d7c4c7056d52be62f693e Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 14 Aug 2025 19:17:48 +0200 Subject: [PATCH] [unity] Fixed "Apply Additive Material" incorrectly set based on atlas workflow, added Spine Preferences setting instead. Closes #2908. --- .../Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs | 2 +- .../Spine/Editor/spine-unity/Editor/Utility/Preferences.cs | 6 ++++++ .../Editor/spine-unity/Editor/Windows/SpinePreferences.cs | 5 +++++ spine-unity/Assets/Spine/package.json | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs index d8412999d..25a9299be 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs @@ -1125,7 +1125,7 @@ namespace Spine.Unity.Editor { skeletonDataAsset.skeletonJSON = spineJson; skeletonDataAsset.defaultMix = SpineEditorUtilities.Preferences.defaultMix; skeletonDataAsset.scale = SpineEditorUtilities.Preferences.defaultScale; - skeletonDataAsset.blendModeMaterials.applyAdditiveMaterial = !SpineEditorUtilities.Preferences.UsesPMAWorkflow; + skeletonDataAsset.blendModeMaterials.applyAdditiveMaterial = SpineEditorUtilities.Preferences.applyAdditiveMaterial; } AssetDatabase.CreateAsset(skeletonDataAsset, filePath); } else { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs index 1da70717a..1f8f2fc84 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs @@ -140,13 +140,17 @@ namespace Spine.Unity.Editor { } } + const string APPLY_ADDITIVE_MATERIAL_KEY = "SPINE_APPLY_ADDITIVE_MATERIAL"; const string BLEND_MODE_MATERIAL_MULTIPLY_KEY = "SPINE_BLENDMODE_MATERIAL_MULTIPLY"; const string BLEND_MODE_MATERIAL_SCREEN_KEY = "SPINE_BLENDMODE_MATERIAL_SCREEN"; const string BLEND_MODE_MATERIAL_ADDITIVE_KEY = "SPINE_BLENDMODE_MATERIAL_ADDITIVE"; + public static bool applyAdditiveMaterial = false; public static string blendModeMaterialMultiply = ""; public static string blendModeMaterialScreen = ""; public static string blendModeMaterialAdditive = ""; + public const bool DEFAULT_APPLY_ADDITIVE_MATERIAL = SpinePreferences.DEFAULT_APPLY_ADDITIVE_MATERIAL; + public const string DEFAULT_BLEND_MODE_MULTIPLY_MATERIAL_STRAIGHT = SpinePreferences.DEFAULT_BLEND_MODE_MULTIPLY_MATERIAL_STRAIGHT; public const string DEFAULT_BLEND_MODE_SCREEN_MATERIAL_STRAIGHT = SpinePreferences.DEFAULT_BLEND_MODE_SCREEN_MATERIAL_STRAIGHT; public const string DEFAULT_BLEND_MODE_ADDITIVE_MATERIAL_STRAIGHT = SpinePreferences.DEFAULT_BLEND_MODE_ADDITIVE_MATERIAL_STRAIGHT; @@ -220,6 +224,7 @@ namespace Spine.Unity.Editor { reloadAfterPlayMode = EditorPrefs.GetBool(RELOAD_AFTER_PLAYMODE_KEY, SpinePreferences.DEFAULT_RELOAD_AFTER_PLAYMODE); setTextureImporterSettings = EditorPrefs.GetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, SpinePreferences.DEFAULT_SET_TEXTUREIMPORTER_SETTINGS); textureSettingsReference = EditorPrefs.GetString(TEXTURE_SETTINGS_REFERENCE_KEY, SpinePreferences.DEFAULT_TEXTURE_SETTINGS_REFERENCE); + applyAdditiveMaterial = EditorPrefs.GetBool(APPLY_ADDITIVE_MATERIAL_KEY, SpinePreferences.DEFAULT_APPLY_ADDITIVE_MATERIAL); blendModeMaterialMultiply = EditorPrefs.GetString(BLEND_MODE_MATERIAL_MULTIPLY_KEY, ""); blendModeMaterialScreen = EditorPrefs.GetString(BLEND_MODE_MATERIAL_SCREEN_KEY, ""); blendModeMaterialAdditive = EditorPrefs.GetString(BLEND_MODE_MATERIAL_ADDITIVE_KEY, ""); @@ -335,6 +340,7 @@ namespace Spine.Unity.Editor { AssignEditorPrefsAssetReference(ref textureSettingsReference, TEXTURE_SETTINGS_REFERENCE_KEY, DEFAULT_TEXTURE_TEMPLATE); } + SpineEditorUtilities.BoolPrefsField(ref applyAdditiveMaterial, APPLY_ADDITIVE_MATERIAL_KEY, new GUIContent("Apply Additive Material", "The Default Apply Additive Material setting for newly imported SkeletonDataAssets.")); SpineEditorUtilities.MaterialPrefsField(ref blendModeMaterialAdditive, BLEND_MODE_MATERIAL_ADDITIVE_KEY, new GUIContent("Additive Material", "Additive blend mode Material template.")); if (string.IsNullOrEmpty(blendModeMaterialAdditive)) { AssignEditorPrefsAssetReference(ref blendModeMaterialAdditive, BLEND_MODE_MATERIAL_ADDITIVE_KEY, DEFAULT_BLEND_MODE_ADDITIVE_MATERIAL); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs index 50b3be96c..ef731e6a1 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs @@ -125,6 +125,9 @@ namespace Spine.Unity.Editor { return true; } + internal const bool DEFAULT_APPLY_ADDITIVE_MATERIAL = false; + public bool applyAdditiveMaterial = DEFAULT_APPLY_ADDITIVE_MATERIAL; + public const string DEFAULT_TEXTURE_PRESET_STRAIGHT = "StraightAlphaPreset"; public const string DEFAULT_TEXTURE_PRESET_PMA = "PMATexturePreset"; public const string DEFAULT_TEXTURE_PRESET = DEFAULT_TEXTURE_PRESET_STRAIGHT; @@ -338,6 +341,8 @@ namespace Spine.Unity.Editor { } } bool isTexturePresetPMA = IsPMAWorkflow(textureSettingsRef.stringValue); + EditorGUILayout.PropertyField(settings.FindProperty("applyAdditiveMaterial"), + new GUIContent("Apply Additive Material", "The Default Apply Additive Material setting for newly imported SkeletonDataAssets.")); ShowBlendModeMaterialProperty(blendModeMaterialAdditive, "Additive", isTexturePresetPMA); ShowBlendModeMaterialProperty(blendModeMaterialMultiply, "Multiply", isTexturePresetPMA); ShowBlendModeMaterialProperty(blendModeMaterialScreen, "Screen", isTexturePresetPMA); diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index 51dd549d4..2c6019000 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-unity", "displayName": "spine-unity Runtime", "description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.", - "version": "4.3.5", + "version": "4.3.6", "unity": "2018.3", "author": { "name": "Esoteric Software",