From 8770e319c5735745e506aad413dc231e0bbc99c3 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 13 Sep 2021 17:04:23 +0200 Subject: [PATCH] [unity] Fixed compile errors introduced by removed FindSlotIndex and FindBoneIndex methods. See commit dc9a6eb, see #1951. --- .../EquipSystemExample.cs | 2 +- spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs | 4 ++-- .../Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs | 4 ++-- .../Scripts/Sample Components/Legacy/SpriteAttacher.cs | 2 +- .../Spine Examples/Scripts/SpineboyFacialExpression.cs | 4 ++-- .../Editor/Components/PointFollowerInspector.cs | 6 +++--- .../Editor/Components/SkeletonGraphicInspector.cs | 3 ++- .../Editor/Components/SkeletonRendererInspector.cs | 3 ++- .../Editor/Components/SkeletonUtilityBoneInspector.cs | 2 +- .../Editor/spine-unity/Editor/Windows/SkeletonBaker.cs | 6 ++---- .../Components/Following/BoundingBoxFollower.cs | 3 +-- .../Components/Following/BoundingBoxFollowerGraphic.cs | 3 +-- .../spine-unity/Components/Following/PointFollower.cs | 6 +++--- .../Components/RootMotion/SkeletonRootMotionBase.cs | 8 ++++---- .../Components/SkeletonUtility/SkeletonUtility.cs | 2 +- .../Assets/Spine/Runtime/spine-unity/SpineAttributes.cs | 5 ++++- 16 files changed, 32 insertions(+), 31 deletions(-) diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs index 3e9cebc10..624eab6b5 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs @@ -67,7 +67,7 @@ namespace Spine.Unity.Examples { EquipHook howToEquip = equippables.Find(x => x.type == equipType); var skeletonData = skeletonDataAsset.GetSkeletonData(true); - int slotIndex = skeletonData.FindSlotIndex(howToEquip.slot); + int slotIndex = skeletonData.FindSlot(howToEquip.slot).Index; var attachment = GenerateAttachmentFromEquipAsset(asset, slotIndex, howToEquip.templateSkin, howToEquip.templateAttachment); target.Equip(slotIndex, howToEquip.templateAttachment, attachment); } diff --git a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs index 26a73b4fd..5dfa5abb9 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs @@ -91,7 +91,7 @@ namespace Spine.Unity.Examples { // Step 1.4 Add the remapped clone to the new custom skin. // Let's do this for the visor. - int visorSlotIndex = skeleton.FindSlotIndex(visorSlot); // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster. + int visorSlotIndex = skeleton.Data.FindSlot(visorSlot).Index; // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster. Attachment templateAttachment = templateSkin.GetAttachment(visorSlotIndex, visorKey); // STEP 1.1 // Note: Each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true` creates @@ -100,7 +100,7 @@ namespace Spine.Unity.Examples { customSkin.SetAttachment(visorSlotIndex, visorKey, newAttachment); // STEP 1.4 // And now for the gun. - int gunSlotIndex = skeleton.FindSlotIndex(gunSlot); + int gunSlotIndex = skeleton.Data.FindSlot(gunSlot).Index; Attachment templateGun = templateSkin.GetAttachment(gunSlotIndex, gunKey); // STEP 1.1 Attachment newGun = templateGun.GetRemappedClone(gunSprite, sourceMaterial, pivotShiftsMeshUVCoords: false); // STEP 1.2 - 1.3 if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4 diff --git a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs index f606d5e4f..f3b9fdde9 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs @@ -93,7 +93,7 @@ namespace Spine.Unity.Examples { // Step 1.4 Add the remapped clone to the new custom skin. // Let's do this for the visor. - int visorSlotIndex = skeleton.FindSlotIndex(visorSlot); // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster. + int visorSlotIndex = skeleton.Data.FindSlot(visorSlot).Index; // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster. Attachment baseAttachment = baseSkin.GetAttachment(visorSlotIndex, visorKey); // STEP 1.1 // Note: Each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true` creates @@ -102,7 +102,7 @@ namespace Spine.Unity.Examples { customSkin.SetAttachment(visorSlotIndex, visorKey, newAttachment); // STEP 1.4 // And now for the gun. - int gunSlotIndex = skeleton.FindSlotIndex(gunSlot); + int gunSlotIndex = skeleton.Data.FindSlot(gunSlot).Index; Attachment baseGun = baseSkin.GetAttachment(gunSlotIndex, gunKey); // STEP 1.1 Attachment newGun = baseGun.GetRemappedClone(gunSprite, sourceMaterial); // STEP 1.2 - 1.3 if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4 diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs index 98e5a1751..9aef002c6 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs @@ -170,7 +170,7 @@ namespace Spine.Unity.Examples { public static RegionAttachment AddUnitySprite (this SkeletonData skeletonData, string slotName, Sprite sprite, string skinName, Shader shader, bool applyPMA, float rotation = 0f) { RegionAttachment att = applyPMA ? sprite.ToRegionAttachmentPMAClone(shader, rotation: rotation) : sprite.ToRegionAttachment(new Material(shader), rotation); - var slotIndex = skeletonData.FindSlotIndex(slotName); + var slotIndex = skeletonData.FindSlot(slotName).Index; Skin skin = skeletonData.DefaultSkin; if (skinName != "") skin = skeletonData.FindSkin(skinName); diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs index f4942b9a6..3b6d7a1c1 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs @@ -60,11 +60,11 @@ namespace Spine.Unity.Examples { eyeSlot = skeleton.FindSlot(eyeSlotName); mouthSlot = skeleton.FindSlot(mouthSlotName); - int eyeSlotIndex = skeleton.FindSlotIndex(eyeSlotName); + int eyeSlotIndex = skeleton.Data.FindSlot(eyeSlotName).Index; shockEye = skeleton.GetAttachment(eyeSlotIndex, shockEyeName); normalEye = skeleton.GetAttachment(eyeSlotIndex, normalEyeName); - int mouthSlotIndex = skeleton.FindSlotIndex(mouthSlotName); + int mouthSlotIndex = skeleton.Data.FindSlot(mouthSlotName).Index; shockMouth = skeleton.GetAttachment(mouthSlotIndex, shockMouthName); normalMouth = skeleton.GetAttachment(mouthSlotIndex, normalMouthName); } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/PointFollowerInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/PointFollowerInspector.cs index c47de34f5..ae05340bc 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/PointFollowerInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/PointFollowerInspector.cs @@ -99,9 +99,9 @@ namespace Spine.Unity.Editor { if (currentSkin != skeleton.Data.DefaultSkin) DrawPointsInSkin(skeleton.Data.DefaultSkin, skeleton, skeletonTransform); if (currentSkin != null) DrawPointsInSkin(currentSkin, skeleton, skeletonTransform); } else { - int slotIndex = skeleton.FindSlotIndex(slotName.stringValue); - if (slotIndex >= 0) { - var slot = skeleton.Slots.Items[slotIndex]; + Slot slot = skeleton.FindSlot(slotName.stringValue); + if (slot != null) { + int slotIndex = slot.Data.Index; var point = skeleton.GetAttachment(slotIndex, pointAttachmentName.stringValue) as PointAttachment; if (point != null) { DrawPointAttachmentWithLabel(point, slot.Bone, skeletonTransform); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs index e98a65d2c..c4c6982d2 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs @@ -360,7 +360,8 @@ namespace Spine.Unity.Editor { int lastSlot = skeleton.Slots.Count - 1; if (skeleton != null) { for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) { - int index = skeleton.FindSlotIndex(separatorSlotNames.GetArrayElementAtIndex(i).stringValue); + string slotName = separatorSlotNames.GetArrayElementAtIndex(i).stringValue; + int index = skeleton.Data.FindSlot(slotName).Index; if (index == 0 || index == lastSlot) { hasTerminalSlot = true; break; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs index a21c01d7b..c0b835ff4 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs @@ -482,7 +482,8 @@ namespace Spine.Unity.Editor { int lastSlot = skeleton.Slots.Count - 1; if (skeleton != null) { for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) { - int index = skeleton.FindSlotIndex(separatorSlotNames.GetArrayElementAtIndex(i).stringValue); + string slotName = separatorSlotNames.GetArrayElementAtIndex(i).stringValue; + int index = skeleton.Data.FindSlot(slotName).Index; if (index == 0 || index == lastSlot) { hasTerminalSlot = true; break; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs index 5603d016b..2cb4e9100 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs @@ -95,7 +95,7 @@ namespace Spine.Unity.Editor { Slot slot = skeletonUtility.Skeleton.Slots.Items[i]; if (slot.Bone == utilityBone.bone) { var slotAttachments = new List(); - int slotIndex = skeleton.FindSlotIndex(slot.Data.Name); + int slotIndex = skeleton.Data.FindSlot(slot.Data.Name).Index; skin.GetAttachments(slotIndex, slotAttachments); var boundingBoxes = new List(); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs index 88e0b826c..284cc803a 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs @@ -764,8 +764,7 @@ namespace Spine.Unity.Editor { if (bakeIK) { foreach (IkConstraint i in skeleton.IkConstraints) { foreach (Bone b in i.Bones) { - int index = skeleton.FindBoneIndex(b.Data.Name); - ignoreRotateTimelineIndexes.Add(index); + ignoreRotateTimelineIndexes.Add(b.Data.Index); BakeBoneConstraints(b, animation, clip); } } @@ -773,8 +772,7 @@ namespace Spine.Unity.Editor { foreach (Bone b in skeleton.Bones) { if (!b.Data.TransformMode.InheritsRotation()) { - int index = skeleton.FindBoneIndex(b.Data.Name); - + int index = b.Data.Index; if (ignoreRotateTimelineIndexes.Contains(index) == false) { ignoreRotateTimelineIndexes.Add(index); BakeBoneConstraints(b, animation, clip); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs index 0511eb80e..8f8ca3c3e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs @@ -118,13 +118,12 @@ namespace Spine.Unity { if (skeleton == null) return; slot = skeleton.FindSlot(slotName); - int slotIndex = skeleton.FindSlotIndex(slotName); - if (slot == null) { if (BoundingBoxFollower.DebugMessages) Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollower on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name)); return; } + int slotIndex = slot.Data.Index; int requiredCollidersCount = 0; var colliders = GetComponents(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs index 36d7fcbd3..032952b0b 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs @@ -118,13 +118,12 @@ namespace Spine.Unity { if (skeleton == null) return; slot = skeleton.FindSlot(slotName); - int slotIndex = skeleton.FindSlotIndex(slotName); - if (slot == null) { if (BoundingBoxFollowerGraphic.DebugMessages) Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollowerGraphic on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name)); return; } + int slotIndex = slot.Data.Index; int requiredCollidersCount = 0; var colliders = GetComponents(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs index 62a20e3bf..0267c514e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs @@ -92,9 +92,9 @@ namespace Spine.Unity { if (!string.IsNullOrEmpty(pointAttachmentName)) { var skeleton = skeletonRenderer.Skeleton; - int slotIndex = skeleton.FindSlotIndex(slotName); - if (slotIndex >= 0) { - var slot = skeleton.slots.Items[slotIndex]; + Slot slot = skeleton.FindSlot(slotName); + if (slot != null) { + int slotIndex = slot.Data.Index; bone = slot.bone; point = skeleton.GetAttachment(slotIndex, pointAttachmentName) as PointAttachment; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs index ecf8925fd..71e091c1c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs @@ -151,10 +151,10 @@ namespace Spine.Unity { public void SetRootMotionBone (string name) { var skeleton = skeletonComponent.Skeleton; - int index = skeleton.FindBoneIndex(name); - if (index >= 0) { - this.rootMotionBoneIndex = index; - this.rootMotionBone = skeleton.bones.Items[index]; + Bone bone = skeleton.FindBone(name); + if (bone != null) { + this.rootMotionBoneIndex = bone.Data.Index; + this.rootMotionBone = bone; } else { Debug.Log("Bone named \"" + name + "\" could not be found."); this.rootMotionBoneIndex = 0; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs index 9860ea3df..d5f150d1b 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs @@ -53,7 +53,7 @@ namespace Spine.Unity { return null; } - var attachment = skin.GetAttachment(skeleton.FindSlotIndex(slotName), attachmentName); + var attachment = skin.GetAttachment(skeleton.Data.FindSlot(slotName).Index, attachmentName); if (attachment == null) { Debug.LogFormat("Attachment in slot '{0}' named '{1}' not found in skin '{2}'.", slotName, attachmentName, skin.name); return null; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs index 678def405..2439a1887 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs @@ -252,7 +252,10 @@ namespace Spine.Unity { public static Spine.Attachment GetAttachment (string attachmentPath, Spine.SkeletonData skeletonData) { var hierarchy = SpineAttachment.GetHierarchy(attachmentPath); - return string.IsNullOrEmpty(hierarchy.name) ? null : skeletonData.FindSkin(hierarchy.skin).GetAttachment(skeletonData.FindSlotIndex(hierarchy.slot), hierarchy.name); + return string.IsNullOrEmpty(hierarchy.name) ? + null : + skeletonData.FindSkin(hierarchy.skin).GetAttachment( + skeletonData.FindSlot(hierarchy.slot).Index, hierarchy.name); } public static Spine.Attachment GetAttachment (string attachmentPath, SkeletonDataAsset skeletonDataAsset) {