• Unity
  • Break change with slotIndex

  • Изменено
Related Discussions
...

Breaking change: Removed SkeletonData and Skeleton methods: FindBoneIndex, FindSlotIndex. Bones and slots have an Index field that should be used instead. Be sure to check for e.g. bone == null accordingly before accessing bone.Index.

I used to have this code:

var slotIndex = skeleton.FindSlotIndex(slotName); // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster.

I couldn't find .Index on slot, I only found SequenceIndex

var slot = skeleton.FindSlot(slotName); // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster.
var slotIndex = slot?.SequenceIndex ?? -1; 

But that broke my script. This was in the CustomMixAndMatch code.

What's the suggested update here?

Thanks!

You are accessing instance Slot instead of SlotData, the latter has the Index property.

In case you didn't already check it out, the replacement lines are listed in the 3.8 to 4.0 upgrade:
Spine-Unity 3.8 to 4.0 Upgrade Guide

SlotData slot = skeletonData.FindSlot(slotName); int index = slot != null ? slot.Index : -1;