您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
36 行
833 B
36 行
833 B
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace AxelF {
|
|
|
|
public sealed class AudioAnimEvent : StateMachineBehaviour {
|
|
[FormerlySerializedAs("asset")]
|
|
public Patch patch;
|
|
[Range(0, 30)] public float delay;
|
|
public Vector3 offset = Vector3.up;
|
|
uint handle;
|
|
|
|
public void KeyOn(Animator a) {
|
|
bool looping;
|
|
handle = Synthesizer.KeyOn(out looping, patch, a.transform, offset, delay);
|
|
}
|
|
|
|
public void KeyOff() {
|
|
if (handle != 0) {
|
|
Synthesizer.KeyOff(handle);
|
|
handle = 0;
|
|
}
|
|
}
|
|
|
|
public override void OnStateEnter(Animator animator, AnimatorStateInfo info, int layer) {
|
|
KeyOn(animator);
|
|
}
|
|
|
|
public override void OnStateExit(Animator animator, AnimatorStateInfo info, int layer) {
|
|
KeyOff();
|
|
}
|
|
}
|
|
|
|
} // AxelF
|
|
|