diff --git a/spine-haxe/haxelib.json b/spine-haxe/haxelib.json index cf2fdbdab..53c8ed2d1 100644 --- a/spine-haxe/haxelib.json +++ b/spine-haxe/haxelib.json @@ -17,8 +17,8 @@ "cpp" ], "description": "The official Spine Runtime for Haxe", - "version": "4.2.6", - "releasenote": "Update to 4.2.6", + "version": "4.2.7", + "releasenote": "Update to 4.2.7", "contributors": [ "esotericsoftware" ], diff --git a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx index 62a300cd9..fa583d180 100644 --- a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx +++ b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx @@ -423,6 +423,10 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { _state = null; } if (_skeleton != null) _skeleton = null; + dispatchEventWith(starling.events.Event.REMOVE_FROM_JUGGLER); + removeFromParent(); + + // this will remove also all starling event listeners super.dispose(); } } 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 98afec85a..fe8c5c87f 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 @@ -658,7 +658,6 @@ namespace Spine.Unity.Editor { foreach (Material m in atlasAsset.materials) vestigialMaterials.Add(m); } - protectFromStackGarbageCollection.Add(atlasAsset); atlasAsset.atlasFile = atlasText; @@ -669,6 +668,7 @@ namespace Spine.Unity.Editor { foreach (AtlasPage page in atlas.Pages) pageFiles.Add(page.name); } + bool atlasHasCustomMaterials = HasCustomMaterialsAssigned(vestigialMaterials, primaryName, pageFiles); List populatingMaterials = new List(pageFiles.Count); string materialDirectory = GetMaterialDirectory(assetPath, vestigialMaterials); @@ -685,12 +685,8 @@ namespace Spine.Unity.Editor { } string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]); - - //because this looks silly - if (pageName == primaryName && pageFiles.Count == 1) - pageName = "Material"; - - string materialPath = materialDirectory + "/" + primaryName + "_" + pageName + ".mat"; + string materialFileName = GetPageMaterialName(primaryName, pageName, pageFiles) + ".mat"; + string materialPath = materialDirectory + "/" + materialFileName; Material material = (Material)AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material)); if (material == null) { Shader defaultShader = GetDefaultShader(); @@ -714,10 +710,11 @@ namespace Spine.Unity.Editor { } } - atlasAsset.materials = populatingMaterials.ToArray(); - - for (int i = 0; i < vestigialMaterials.Count; i++) - AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i])); + if (!atlasHasCustomMaterials) { + atlasAsset.materials = populatingMaterials.ToArray(); + for (int i = 0; i < vestigialMaterials.Count; i++) + AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i])); + } if (AssetDatabase.GetAssetPath(atlasAsset) == "") AssetDatabase.CreateAsset(atlasAsset, atlasPath); @@ -727,9 +724,14 @@ namespace Spine.Unity.Editor { EditorUtility.SetDirty(atlasAsset); AssetDatabase.SaveAssets(); - if (pageFiles.Count != atlasAsset.materials.Length) - Debug.LogWarning(string.Format("{0} :: Not all atlas pages were imported. If you rename your image files, please make sure you also edit the filenames specified in the atlas file.", atlasAsset.name), atlasAsset); - else + if (pageFiles.Count != atlasAsset.materials.Length) { + if (atlasHasCustomMaterials) + Debug.LogWarning(string.Format("{0} :: Found custom materials at atlas asset, but atlas page count " + + "changed. Please update the Materials list accordingly.", atlasAsset.name), atlasAsset); + else + Debug.LogWarning(string.Format("{0} :: Not all atlas pages were imported. If you rename your image " + + "files, please make sure you also edit the filenames specified in the atlas file.", atlasAsset.name), atlasAsset); + } else Debug.Log(string.Format("{0} :: Imported with {1} material", atlasAsset.name, atlasAsset.materials.Length), atlasAsset); // Iterate regions and bake marked. @@ -766,6 +768,15 @@ namespace Spine.Unity.Editor { return loadedAtlas != null ? loadedAtlas : atlasAsset; } + static bool HasCustomMaterialsAssigned (List vestigialMaterials, string primaryName, List pageFiles) { + if (pageFiles.Count == 0 || vestigialMaterials.Count == 0) + return false; + + string firstPageName = Path.GetFileNameWithoutExtension(pageFiles[0]); + string defaultMaterialName = GetPageMaterialName(primaryName, firstPageName, pageFiles); + return vestigialMaterials[0].name != defaultMaterialName; + } + public static Shader GetDefaultShader () { Shader shader = Shader.Find(SpineEditorUtilities.Preferences.DefaultShader); if (shader == null) shader = Shader.Find("Spine/Skeleton"); @@ -928,6 +939,13 @@ namespace Spine.Unity.Editor { return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase)); } + static string GetPageMaterialName (string primaryName, string pageName, List pageFiles) { + // use skeleton_Material.mat instead of skeleton_skeleton.mat if we have just a single atlas page + if (pageName == primaryName && pageFiles.Count == 1) + pageName = "Material"; + return primaryName + "_" + pageName; + } + static string GetMaterialDirectory (string assetPath, List previousMaterials) { if (previousMaterials.Count > 0 && previousMaterials[0] != null) { string materialPath = AssetDatabase.GetAssetPath(previousMaterials[0]); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl index 8368d66b0..ad99446fe 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl @@ -178,13 +178,13 @@ VertexOutput vert(appdata v) { GetWorldSpaceNormalizeViewDir(positionWS), o.pos.xy, ignoredProbeOcclusion, - shadowMask); + shadowMask) * v.color.a; #else // _ADAPTIVE_PROBE_VOLUMES_PER_PIXEL half3 bakedGI = half3(0.0, 0.0, 0.0); o.positionCS = o.pos; #endif #else - half3 bakedGI = SAMPLE_GI(v.lightmapUV, vertexSH, normalWS); + half3 bakedGI = SAMPLE_GI(v.lightmapUV, vertexSH, normalWS) * v.color.a; #endif color.rgb += bakedGI; o.color = color; @@ -223,7 +223,7 @@ half4 frag(VertexOutput i GetWorldSpaceNormalizeViewDir(i.positionWS), i.positionCS.xy, ignoredProbeOcclusion, - shadowMask); + shadowMask) * i.color.a; i.color.rgb += bakedGI; #endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json index 4724b1a95..4b985624f 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.urp-shaders", "displayName": "Spine Universal RP Shaders", "description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "4.2.42", + "version": "4.2.43", "unity": "2019.3", "author": { "name": "Esoteric Software",