TaiZhouCangChu_VRanime/Assets/动画/Scripts/LoopAnimationOn.cs

41 lines
1.1 KiB
C#
Raw Blame History

using UnityEngine;
public class LoopAnimationOn : MonoBehaviour
{
public string animationStateName;
public Vector3 targetPosition; // ָ<><D6B8><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
private Animator animator;
public int aa = 00;
void Start()
{
animator = GetComponent<Animator>();
if (animator == null)
{
Debug.LogError("Animator component not found on the object.");
}
}
public void ResetAnimationPlay()
{
if (animator != null && !string.IsNullOrEmpty(animationStateName))
{
// <20><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
Quaternion specificRotation = Quaternion.Euler(0, aa, 0);
animator.Play(animationStateName, -1, 0f);
// <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>嵽ָ<E5B5BD><D6B8>λ<EFBFBD><CEBB>
if (targetPosition != null)
{
transform.localPosition = targetPosition;
transform.rotation = specificRotation;
}
}
else
{
Debug.LogError("Animation state name is not set or Animator is null.");
}
}
}