短くしたい場合は、ラムダを使用できます。
TrackEntry trackEntry = skeletonAnimation.AnimationState.AddAnimation(1, "run", false, 0);
trackEntry.Start += (entry) => { skeletonAnimation.AnimationState.SetAnimation(2, "runeffect", false); };
または拡張メソッドとして:
public static class AnimationStateExtensions {
public static TrackEntry AddSyncedAnimations (this Spine.AnimationState animationState,
int trackIndex0, string animationName0, bool loop0, float delay0,
int trackIndex1, string animationName1, bool loop1) {
TrackEntry trackEntry = animationState.AddAnimation(trackIndex0, animationName0, loop0, delay0);
trackEntry.Start += (e) => { animationState.SetAnimation(trackIndex1, animationName1, loop1); };
return trackEntry;
}
}
skeletonAnimation.AnimationState.AddSyncedAnimations(1, "run", false, 0,
2, "runeffect", false);
You could just use a lambda if you want to keep it short:
TrackEntry trackEntry = skeletonAnimation.AnimationState.AddAnimation(1, "run", false, 0);
trackEntry.Start += (entry) => { skeletonAnimation.AnimationState.SetAnimation(2, "runeffect", false); };
Or as an extension method:
public static class AnimationStateExtensions {
public static TrackEntry AddSyncedAnimations (this Spine.AnimationState animationState,
int trackIndex0, string animationName0, bool loop0, float delay0,
int trackIndex1, string animationName1, bool loop1) {
TrackEntry trackEntry = animationState.AddAnimation(trackIndex0, animationName0, loop0, delay0);
trackEntry.Start += (e) => { animationState.SetAnimation(trackIndex1, animationName1, loop1); };
return trackEntry;
}
}
skeletonAnimation.AnimationState.AddSyncedAnimations(1, "run", false, 0,
2, "runeffect", false);