[unity] Fixed compile errors introduced by removed FindSlotIndex and FindBoneIndex methods. See commit dc9a6eb, see #1951.

This commit is contained in:
Harald Csaszar 2021-09-13 17:04:23 +02:00
parent afa9a873ad
commit 8770e319c5
16 changed files with 32 additions and 31 deletions

View File

@ -67,7 +67,7 @@ namespace Spine.Unity.Examples {
EquipHook howToEquip = equippables.Find(x => x.type == equipType); EquipHook howToEquip = equippables.Find(x => x.type == equipType);
var skeletonData = skeletonDataAsset.GetSkeletonData(true); 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); var attachment = GenerateAttachmentFromEquipAsset(asset, slotIndex, howToEquip.templateSkin, howToEquip.templateAttachment);
target.Equip(slotIndex, howToEquip.templateAttachment, attachment); target.Equip(slotIndex, howToEquip.templateAttachment, attachment);
} }

View File

@ -91,7 +91,7 @@ namespace Spine.Unity.Examples {
// Step 1.4 Add the remapped clone to the new custom skin. // Step 1.4 Add the remapped clone to the new custom skin.
// Let's do this for the visor. // 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 Attachment templateAttachment = templateSkin.GetAttachment(visorSlotIndex, visorKey); // STEP 1.1
// Note: Each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true` creates // 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 customSkin.SetAttachment(visorSlotIndex, visorKey, newAttachment); // STEP 1.4
// And now for the gun. // 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 templateGun = templateSkin.GetAttachment(gunSlotIndex, gunKey); // STEP 1.1
Attachment newGun = templateGun.GetRemappedClone(gunSprite, sourceMaterial, pivotShiftsMeshUVCoords: false); // STEP 1.2 - 1.3 Attachment newGun = templateGun.GetRemappedClone(gunSprite, sourceMaterial, pivotShiftsMeshUVCoords: false); // STEP 1.2 - 1.3
if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4 if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4

View File

@ -93,7 +93,7 @@ namespace Spine.Unity.Examples {
// Step 1.4 Add the remapped clone to the new custom skin. // Step 1.4 Add the remapped clone to the new custom skin.
// Let's do this for the visor. // 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 Attachment baseAttachment = baseSkin.GetAttachment(visorSlotIndex, visorKey); // STEP 1.1
// Note: Each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true` creates // 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 customSkin.SetAttachment(visorSlotIndex, visorKey, newAttachment); // STEP 1.4
// And now for the gun. // 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 baseGun = baseSkin.GetAttachment(gunSlotIndex, gunKey); // STEP 1.1
Attachment newGun = baseGun.GetRemappedClone(gunSprite, sourceMaterial); // STEP 1.2 - 1.3 Attachment newGun = baseGun.GetRemappedClone(gunSprite, sourceMaterial); // STEP 1.2 - 1.3
if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4 if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4

View File

@ -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) { 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); 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; Skin skin = skeletonData.DefaultSkin;
if (skinName != "") if (skinName != "")
skin = skeletonData.FindSkin(skinName); skin = skeletonData.FindSkin(skinName);

View File

@ -60,11 +60,11 @@ namespace Spine.Unity.Examples {
eyeSlot = skeleton.FindSlot(eyeSlotName); eyeSlot = skeleton.FindSlot(eyeSlotName);
mouthSlot = skeleton.FindSlot(mouthSlotName); mouthSlot = skeleton.FindSlot(mouthSlotName);
int eyeSlotIndex = skeleton.FindSlotIndex(eyeSlotName); int eyeSlotIndex = skeleton.Data.FindSlot(eyeSlotName).Index;
shockEye = skeleton.GetAttachment(eyeSlotIndex, shockEyeName); shockEye = skeleton.GetAttachment(eyeSlotIndex, shockEyeName);
normalEye = skeleton.GetAttachment(eyeSlotIndex, normalEyeName); normalEye = skeleton.GetAttachment(eyeSlotIndex, normalEyeName);
int mouthSlotIndex = skeleton.FindSlotIndex(mouthSlotName); int mouthSlotIndex = skeleton.Data.FindSlot(mouthSlotName).Index;
shockMouth = skeleton.GetAttachment(mouthSlotIndex, shockMouthName); shockMouth = skeleton.GetAttachment(mouthSlotIndex, shockMouthName);
normalMouth = skeleton.GetAttachment(mouthSlotIndex, normalMouthName); normalMouth = skeleton.GetAttachment(mouthSlotIndex, normalMouthName);
} }

View File

@ -99,9 +99,9 @@ namespace Spine.Unity.Editor {
if (currentSkin != skeleton.Data.DefaultSkin) DrawPointsInSkin(skeleton.Data.DefaultSkin, skeleton, skeletonTransform); if (currentSkin != skeleton.Data.DefaultSkin) DrawPointsInSkin(skeleton.Data.DefaultSkin, skeleton, skeletonTransform);
if (currentSkin != null) DrawPointsInSkin(currentSkin, skeleton, skeletonTransform); if (currentSkin != null) DrawPointsInSkin(currentSkin, skeleton, skeletonTransform);
} else { } else {
int slotIndex = skeleton.FindSlotIndex(slotName.stringValue); Slot slot = skeleton.FindSlot(slotName.stringValue);
if (slotIndex >= 0) { if (slot != null) {
var slot = skeleton.Slots.Items[slotIndex]; int slotIndex = slot.Data.Index;
var point = skeleton.GetAttachment(slotIndex, pointAttachmentName.stringValue) as PointAttachment; var point = skeleton.GetAttachment(slotIndex, pointAttachmentName.stringValue) as PointAttachment;
if (point != null) { if (point != null) {
DrawPointAttachmentWithLabel(point, slot.Bone, skeletonTransform); DrawPointAttachmentWithLabel(point, slot.Bone, skeletonTransform);

View File

@ -360,7 +360,8 @@ namespace Spine.Unity.Editor {
int lastSlot = skeleton.Slots.Count - 1; int lastSlot = skeleton.Slots.Count - 1;
if (skeleton != null) { if (skeleton != null) {
for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) { 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) { if (index == 0 || index == lastSlot) {
hasTerminalSlot = true; hasTerminalSlot = true;
break; break;

View File

@ -482,7 +482,8 @@ namespace Spine.Unity.Editor {
int lastSlot = skeleton.Slots.Count - 1; int lastSlot = skeleton.Slots.Count - 1;
if (skeleton != null) { if (skeleton != null) {
for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) { 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) { if (index == 0 || index == lastSlot) {
hasTerminalSlot = true; hasTerminalSlot = true;
break; break;

View File

@ -95,7 +95,7 @@ namespace Spine.Unity.Editor {
Slot slot = skeletonUtility.Skeleton.Slots.Items[i]; Slot slot = skeletonUtility.Skeleton.Slots.Items[i];
if (slot.Bone == utilityBone.bone) { if (slot.Bone == utilityBone.bone) {
var slotAttachments = new List<Skin.SkinEntry>(); var slotAttachments = new List<Skin.SkinEntry>();
int slotIndex = skeleton.FindSlotIndex(slot.Data.Name); int slotIndex = skeleton.Data.FindSlot(slot.Data.Name).Index;
skin.GetAttachments(slotIndex, slotAttachments); skin.GetAttachments(slotIndex, slotAttachments);
var boundingBoxes = new List<BoundingBoxAttachment>(); var boundingBoxes = new List<BoundingBoxAttachment>();

View File

@ -764,8 +764,7 @@ namespace Spine.Unity.Editor {
if (bakeIK) { if (bakeIK) {
foreach (IkConstraint i in skeleton.IkConstraints) { foreach (IkConstraint i in skeleton.IkConstraints) {
foreach (Bone b in i.Bones) { foreach (Bone b in i.Bones) {
int index = skeleton.FindBoneIndex(b.Data.Name); ignoreRotateTimelineIndexes.Add(b.Data.Index);
ignoreRotateTimelineIndexes.Add(index);
BakeBoneConstraints(b, animation, clip); BakeBoneConstraints(b, animation, clip);
} }
} }
@ -773,8 +772,7 @@ namespace Spine.Unity.Editor {
foreach (Bone b in skeleton.Bones) { foreach (Bone b in skeleton.Bones) {
if (!b.Data.TransformMode.InheritsRotation()) { if (!b.Data.TransformMode.InheritsRotation()) {
int index = skeleton.FindBoneIndex(b.Data.Name); int index = b.Data.Index;
if (ignoreRotateTimelineIndexes.Contains(index) == false) { if (ignoreRotateTimelineIndexes.Contains(index) == false) {
ignoreRotateTimelineIndexes.Add(index); ignoreRotateTimelineIndexes.Add(index);
BakeBoneConstraints(b, animation, clip); BakeBoneConstraints(b, animation, clip);

View File

@ -118,13 +118,12 @@ namespace Spine.Unity {
if (skeleton == null) if (skeleton == null)
return; return;
slot = skeleton.FindSlot(slotName); slot = skeleton.FindSlot(slotName);
int slotIndex = skeleton.FindSlotIndex(slotName);
if (slot == null) { if (slot == null) {
if (BoundingBoxFollower.DebugMessages) if (BoundingBoxFollower.DebugMessages)
Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollower on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name)); Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollower on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name));
return; return;
} }
int slotIndex = slot.Data.Index;
int requiredCollidersCount = 0; int requiredCollidersCount = 0;
var colliders = GetComponents<PolygonCollider2D>(); var colliders = GetComponents<PolygonCollider2D>();

View File

@ -118,13 +118,12 @@ namespace Spine.Unity {
if (skeleton == null) if (skeleton == null)
return; return;
slot = skeleton.FindSlot(slotName); slot = skeleton.FindSlot(slotName);
int slotIndex = skeleton.FindSlotIndex(slotName);
if (slot == null) { if (slot == null) {
if (BoundingBoxFollowerGraphic.DebugMessages) if (BoundingBoxFollowerGraphic.DebugMessages)
Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollowerGraphic on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name)); Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollowerGraphic on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name));
return; return;
} }
int slotIndex = slot.Data.Index;
int requiredCollidersCount = 0; int requiredCollidersCount = 0;
var colliders = GetComponents<PolygonCollider2D>(); var colliders = GetComponents<PolygonCollider2D>();

View File

@ -92,9 +92,9 @@ namespace Spine.Unity {
if (!string.IsNullOrEmpty(pointAttachmentName)) { if (!string.IsNullOrEmpty(pointAttachmentName)) {
var skeleton = skeletonRenderer.Skeleton; var skeleton = skeletonRenderer.Skeleton;
int slotIndex = skeleton.FindSlotIndex(slotName); Slot slot = skeleton.FindSlot(slotName);
if (slotIndex >= 0) { if (slot != null) {
var slot = skeleton.slots.Items[slotIndex]; int slotIndex = slot.Data.Index;
bone = slot.bone; bone = slot.bone;
point = skeleton.GetAttachment(slotIndex, pointAttachmentName) as PointAttachment; point = skeleton.GetAttachment(slotIndex, pointAttachmentName) as PointAttachment;
} }

View File

@ -151,10 +151,10 @@ namespace Spine.Unity {
public void SetRootMotionBone (string name) { public void SetRootMotionBone (string name) {
var skeleton = skeletonComponent.Skeleton; var skeleton = skeletonComponent.Skeleton;
int index = skeleton.FindBoneIndex(name); Bone bone = skeleton.FindBone(name);
if (index >= 0) { if (bone != null) {
this.rootMotionBoneIndex = index; this.rootMotionBoneIndex = bone.Data.Index;
this.rootMotionBone = skeleton.bones.Items[index]; this.rootMotionBone = bone;
} else { } else {
Debug.Log("Bone named \"" + name + "\" could not be found."); Debug.Log("Bone named \"" + name + "\" could not be found.");
this.rootMotionBoneIndex = 0; this.rootMotionBoneIndex = 0;

View File

@ -53,7 +53,7 @@ namespace Spine.Unity {
return null; return null;
} }
var attachment = skin.GetAttachment(skeleton.FindSlotIndex(slotName), attachmentName); var attachment = skin.GetAttachment(skeleton.Data.FindSlot(slotName).Index, attachmentName);
if (attachment == null) { if (attachment == null) {
Debug.LogFormat("Attachment in slot '{0}' named '{1}' not found in skin '{2}'.", slotName, attachmentName, skin.name); Debug.LogFormat("Attachment in slot '{0}' named '{1}' not found in skin '{2}'.", slotName, attachmentName, skin.name);
return null; return null;

View File

@ -252,7 +252,10 @@ namespace Spine.Unity {
public static Spine.Attachment GetAttachment (string attachmentPath, Spine.SkeletonData skeletonData) { public static Spine.Attachment GetAttachment (string attachmentPath, Spine.SkeletonData skeletonData) {
var hierarchy = SpineAttachment.GetHierarchy(attachmentPath); 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) { public static Spine.Attachment GetAttachment (string attachmentPath, SkeletonDataAsset skeletonDataAsset) {