initial commit

This commit is contained in:
2026-05-16 16:12:06 +08:00
parent a7e4ebd4f8
commit f432cfa92f
1008 changed files with 409466 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This class allows an audio clip to be played during an animation state.
/// </summary>
public class PlayAudioClip : StateMachineBehaviour
{
/// <summary>
/// The point in normalized time where the clip should play.
/// </summary>
public float t = 0.5f;
/// <summary>
/// If greater than zero, the normalized time will be (normalizedTime % modulus).
/// This is used to repeat the audio clip when the animation state loops.
/// </summary>
public float modulus = 0f;
/// <summary>
/// The audio clip to be played.
/// </summary>
public AudioClip clip;
float last_t = -1f;
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
var nt = stateInfo.normalizedTime;
if (modulus > 0f) nt %= modulus;
if (nt >= t && last_t < t)
AudioSource.PlayClipAtPoint(clip, animator.transform.position);
last_t = nt;
}
}