38 lines
884 B
C#
38 lines
884 B
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
public class ActorAction : MonoBehaviour
|
|||
|
{
|
|||
|
public Animator _Animator;
|
|||
|
public List<string> _PlayingAnim = new List<string>();
|
|||
|
public float _PlayingAnimIdx = -1;
|
|||
|
|
|||
|
private int _LastPlayAnimIdx = -1;
|
|||
|
|
|||
|
private void InitAnimator()
|
|||
|
{
|
|||
|
if (_Animator == null)
|
|||
|
{
|
|||
|
_Animator = gameObject.GetComponentInChildren<Animator>();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void Update()
|
|||
|
{
|
|||
|
if (_LastPlayAnimIdx != (int)_PlayingAnimIdx)
|
|||
|
{
|
|||
|
if(_PlayingAnimIdx >= 0 && _PlayingAnimIdx < _PlayingAnim.Count)
|
|||
|
PlayAnim(_PlayingAnim[(int)_PlayingAnimIdx]);
|
|||
|
_LastPlayAnimIdx = (int)_PlayingAnimIdx;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void PlayAnim(string animName)
|
|||
|
{
|
|||
|
InitAnimator();
|
|||
|
|
|||
|
_Animator.CrossFade(animName, 0);
|
|||
|
}
|
|||
|
}
|