mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
23 lines
722 B
C#
23 lines
722 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Spine.Unity.Examples {
|
|
|
|
// This StateMachineBehaviour handles sending the Mecanim state information to the component that handles playing the Spine animations.
|
|
public class MecanimToAnimationHandleExample : StateMachineBehaviour {
|
|
SkeletonAnimationHandleExample animationHandle;
|
|
bool initialized;
|
|
|
|
override public void OnStateEnter (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
|
|
if (!initialized) {
|
|
animationHandle = animator.GetComponent<SkeletonAnimationHandleExample>();
|
|
initialized = true;
|
|
}
|
|
|
|
animationHandle.PlayAnimationForState(stateInfo.shortNameHash, layerIndex);
|
|
}
|
|
}
|
|
|
|
}
|