using System.Collections; using System.Collections.Generic; using UnityEngine; public class PCUIActor : MonoBehaviour { public void Set() { Play_UIAttack(); } private void OnEnable() { Play_UIAttack(); } void Play_UIAttack() { if (gameObject.activeInHierarchy) StartCoroutine(Co_UIAttack()); } IEnumerator Co_UIAttack() { var anim = GetComponent(); anim.Play("uiattack"); yield return new WaitForSeconds(anim["uiattack"].length); anim.Play("idle"); } }