From 4139546b879fa9a132aae3d2025f529511e6037b Mon Sep 17 00:00:00 2001 From: John Date: Sat, 24 Jun 2017 12:44:38 +0800 Subject: [PATCH 1/4] [csharp] Don't use `DIP_MIX` across tracks. based on https://github.com/EsotericSoftware/spine-runtimes/commit/61e54a5771481f037ee8bdcc9956489d66d15560 --- spine-csharp/src/AnimationState.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 2e46e6511..770fc91e7 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -616,14 +616,10 @@ namespace Spine { propertyIDs.Clear(); var mixingTo = this.mixingTo; - TrackEntry lastEntry = null; var tracksItems = tracks.Items; for (int i = 0, n = tracks.Count; i < n; i++) { var entry = tracksItems[i]; - if (entry != null) { - entry.SetTimelineData(lastEntry, mixingTo, propertyIDs); - lastEntry = entry; - } + if (entry != null) entry.SetTimelineData(null, mixingTo, propertyIDs); } } From 02d1bfc4650878774d2a7a6b365aa339b939811e Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 26 Jun 2017 14:13:16 +0800 Subject: [PATCH 2/4] [unity] Fix SkeletonGraphic.OverrideTexture. --- .../Modules/SkeletonGraphic/SkeletonGraphic.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs index 4e5f4574e..510928c78 100644 --- a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs +++ b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs @@ -122,11 +122,18 @@ namespace Spine.Unity { #region Internals // This is used by the UI system to determine what to put in the MaterialPropertyBlock. - public Texture OverrideTexture { get; set; } + Texture overrideTexture; + public Texture OverrideTexture { + get { return overrideTexture; } + set { + canvasRenderer.SetTexture(value); + overrideTexture = value; + } + } public override Texture mainTexture { get { // Fail loudly when incorrectly set up. - if (OverrideTexture != null) return OverrideTexture; + if (overrideTexture != null) return overrideTexture; return skeletonDataAsset == null ? null : skeletonDataAsset.atlasAssets[0].materials[0].mainTexture; } } From f62e2e12b807fae676dc3b4af5556cb5687984eb Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 26 Jun 2017 14:14:04 +0800 Subject: [PATCH 3/4] [unity] Shorten BoneFollower.SetBone string API. --- spine-unity/Assets/spine-unity/BoneFollower.cs | 4 ++-- .../Editor/BoundingBoxFollowerInspector.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spine-unity/Assets/spine-unity/BoneFollower.cs b/spine-unity/Assets/spine-unity/BoneFollower.cs index c9c7746c9..2681c4ff2 100644 --- a/spine-unity/Assets/spine-unity/BoneFollower.cs +++ b/spine-unity/Assets/spine-unity/BoneFollower.cs @@ -74,7 +74,7 @@ namespace Spine.Unity { /// /// Sets the target bone by its bone name. Returns false if no bone was found. - public bool SetBoneByName (string name) { + public bool SetBone (string name) { bone = skeletonRenderer.skeleton.FindBone(name); if (bone == null) { Debug.LogError("Bone not found: " + name, this); @@ -130,7 +130,7 @@ namespace Spine.Unity { if (bone == null) { if (string.IsNullOrEmpty(boneName)) return; bone = skeletonRenderer.skeleton.FindBone(boneName); - if (!SetBoneByName(boneName)) return; + if (!SetBone(boneName)) return; } Transform thisTransform = this.transform; diff --git a/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/Editor/BoundingBoxFollowerInspector.cs b/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/Editor/BoundingBoxFollowerInspector.cs index f00f3cb3c..8d340d2f3 100644 --- a/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/Editor/BoundingBoxFollowerInspector.cs +++ b/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/Editor/BoundingBoxFollowerInspector.cs @@ -156,7 +156,7 @@ namespace Spine.Unity.Editor { if (Event.current.type == EventType.Repaint) { if (addBoneFollower) { var boneFollower = follower.gameObject.AddComponent(); - boneFollower.SetBoneByName(follower.Slot.Data.BoneData.Name); + boneFollower.SetBone(follower.Slot.Data.BoneData.Name); addBoneFollower = false; } From 83d45b549234a20045894d516dec31f03ab84de7 Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 26 Jun 2017 14:16:14 +0800 Subject: [PATCH 4/4] [tk2d] Allow Spine.AtlasAsset fallback for TK2D in inspector. --- .../Editor/SkeletonDataAssetInspector.cs | 83 +++++++++++-------- .../spine-unity/Mesh Generation/SpineMesh.cs | 2 +- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Asset Types/Editor/SkeletonDataAssetInspector.cs b/spine-unity/Assets/spine-unity/Asset Types/Editor/SkeletonDataAssetInspector.cs index c9fe59276..1d5857438 100644 --- a/spine-unity/Assets/spine-unity/Asset Types/Editor/SkeletonDataAssetInspector.cs +++ b/spine-unity/Assets/spine-unity/Asset Types/Editor/SkeletonDataAssetInspector.cs @@ -74,7 +74,8 @@ namespace Spine.Unity.Editor { SpineEditorUtilities.ConfirmInitialization(); m_skeletonDataAsset = (SkeletonDataAsset)target; - atlasAssets = serializedObject.FindProperty("atlasAssets"); + bool newAtlasAssets = atlasAssets == null; + if (newAtlasAssets) atlasAssets = serializedObject.FindProperty("atlasAssets"); skeletonJSON = serializedObject.FindProperty("skeletonJSON"); scale = serializedObject.FindProperty("scale"); fromAnimation = serializedObject.FindProperty("fromAnimation"); @@ -87,10 +88,10 @@ namespace Spine.Unity.Editor { #endif #if SPINE_TK2D - atlasAssets.isExpanded = false; + if (newAtlasAssets) atlasAssets.isExpanded = false; spriteCollection = serializedObject.FindProperty("spriteCollection"); #else - atlasAssets.isExpanded = true; + if (newAtlasAssets) atlasAssets.isExpanded = true; #endif m_skeletonDataAssetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_skeletonDataAsset)); @@ -470,44 +471,56 @@ namespace Spine.Unity.Editor { if (SpineEditorUtilities.IsSpineData((TextAsset)skeletonJSON.objectReferenceValue) == false) { warnings.Add("Skeleton data file is not a valid JSON or binary file."); } else { - #if !SPINE_TK2D - bool detectedNullAtlasEntry = false; - var atlasList = new List(); - var actualAtlasAssets = m_skeletonDataAsset.atlasAssets; - for (int i = 0; i < actualAtlasAssets.Length; i++) { - if (m_skeletonDataAsset.atlasAssets[i] == null) { - detectedNullAtlasEntry = true; - break; - } else { - atlasList.Add(actualAtlasAssets[i].GetAtlas()); - } - } + #if SPINE_TK2D + bool searchForSpineAtlasAssets = true; + bool isSpriteCollectionNull = spriteCollection.objectReferenceValue == null; + if (!isSpriteCollectionNull) searchForSpineAtlasAssets = false; + //else + // warnings.Add("Your sprite collection may have missing images."); + #else + const bool searchForSpineAtlasAssets = true; + #endif - if (detectedNullAtlasEntry) - warnings.Add("AtlasAsset elements should not be null."); - else { - // Get requirements. - var missingPaths = SpineEditorUtilities.GetRequiredAtlasRegions(AssetDatabase.GetAssetPath((TextAsset)skeletonJSON.objectReferenceValue)); + if (searchForSpineAtlasAssets) { + bool detectedNullAtlasEntry = false; + var atlasList = new List(); + var actualAtlasAssets = m_skeletonDataAsset.atlasAssets; - foreach (var atlas in atlasList) { - for (int i = 0; i < missingPaths.Count; i++) { - if (atlas.FindRegion(missingPaths[i]) != null) { - missingPaths.RemoveAt(i); - i--; - } + for (int i = 0; i < actualAtlasAssets.Length; i++) { + if (m_skeletonDataAsset.atlasAssets[i] == null) { + detectedNullAtlasEntry = true; + break; + } else { + atlasList.Add(actualAtlasAssets[i].GetAtlas()); } } - foreach (var str in missingPaths) - warnings.Add("Missing Region: '" + str + "'"); - + if (detectedNullAtlasEntry) { + warnings.Add("AtlasAsset elements should not be null."); + } else { + // Get requirements. + var missingPaths = SpineEditorUtilities.GetRequiredAtlasRegions(AssetDatabase.GetAssetPath((TextAsset)skeletonJSON.objectReferenceValue)); + + foreach (var atlas in atlasList) { + for (int i = 0; i < missingPaths.Count; i++) { + if (atlas.FindRegion(missingPaths[i]) != null) { + missingPaths.RemoveAt(i); + i--; + } + } + } + + #if SPINE_TK2D + if (missingPaths.Count > 0) + warnings.Add("Missing regions. SkeletonDataAsset requires tk2DSpriteCollectionData or Spine AtlasAssets."); + #endif + + foreach (var str in missingPaths) + warnings.Add("Missing Region: '" + str + "'"); + + } } - #else - if (spriteCollection.objectReferenceValue == null) - warnings.Add("SkeletonDataAsset requires tk2DSpriteCollectionData."); -// else -// warnings.Add("Your sprite collection may have missing images."); - #endif + } } } diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs index d47526721..f910885af 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs @@ -357,7 +357,7 @@ namespace Spine.Unity { material = (Material)((AtlasRegion)rendererObject).page.rendererObject; } #else - Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject; + Material material = (rendererObject is Material) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject; #endif if (current.forceSeparate || (current.rawVertexCount > 0 && !System.Object.ReferenceEquals(current.material, material))) { // Material changed. Add the previous submesh.