轉(zhuǎn)自?參考文章
public SkeletonAnimation skeletonAnimation;
? ? void Start()
? ? {
? ? ? ? var sk_1 = skeletonAnimation.Skeleton.Data.FindSkin("wuqi1");
? ? ? ? var sk_2 = skeletonAnimation.Skeleton.Data.FindSkin("wuqi3");
? ? ? ? Attachment act = null;
? ? ? ? skeletonAnimation.Skeleton.PrintSlot();
? ? ? ? for (int i = 0; i < 40; i++)
? ? ? ? {
? ? ? ? ? ? act = sk_2.GetAttachment(i, "wuqi3");
? ? ? ? ? ? if (act != null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Debug.LogError(i);
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? skeletonAnimation.Skeleton.SetAttachment("wuqi/wuqi1", act, false);
? ? }
Skeleton中添加
public void SetAttachment(string newSlotName, Attachment atta, bool isForce)
{
ExposedList<Slot> slots = this.slots;
for (int i = 0, n = slots.Count; i < n; i++)
? ? ? ? ? ? {
Slot slot = slots.Items[i];
UnityEngine.Debug.Log($"槽位名稱:{slot.data.name}");
if (slot.data.name == newSlotName)
{
slot.attachment = atta;
return;
}
? ? ? ? ? ? }
}
剛開(kāi)始接觸spine,沒(méi)弄明白GetAttachment的第一個(gè)參數(shù)從哪里處理得來(lái)的
調(diào)用GetAttachment時(shí) name參數(shù)不用父節(jié)點(diǎn),SetAttachment時(shí)如果有要加上