Fenrisul d60bc9241c more attributes
more bug fixes
more helper menus
even more examples
2015-01-23 00:01:32 -08:00

37 lines
990 B
C#

using UnityEngine;
using System.Collections;
using Spine;
public class CustomSkin : MonoBehaviour {
[System.Serializable]
public class SkinPair {
[SpineAttachment(currentSkinOnly: false, returnAttachmentPath: true, dataField: "skinSource")]
public string sourceAttachment;
[SpineSlot]
public string targetSlot;
[SpineAttachment(currentSkinOnly: true, placeholdersOnly: true)]
public string targetAttachment;
}
public SkeletonDataAsset skinSource;
public SkinPair[] skinning;
public Skin customSkin;
SkeletonRenderer skeletonRenderer;
void Start() {
skeletonRenderer = GetComponent<SkeletonRenderer>();
Skeleton skeleton = skeletonRenderer.skeleton;
customSkin = new Skin("CustomSkin");
foreach (var pair in skinning) {
var attachment = SpineAttachment.GetAttachment(pair.sourceAttachment, skinSource);
customSkin.AddAttachment(skeleton.FindSlotIndex(pair.targetSlot), pair.targetAttachment, attachment);
}
skeleton.SetSkin(customSkin);
}
}