using System.Collections; using System.Collections.Generic; using UnityEngine; // 单个残影的参数 public struct AfterImageAvatarInfo { } public class AfterImageAvatar : MonoBehaviour { #region inspector public Renderer[] renderers; public Animator animator; #endregion float m_CurTime; float m_LifeTime; public void Initialize(AfterImageAvatarInfo info) { } public void Initialize(UnitController prototype) { transform.position = prototype.transform.position; animator.runtimeAnimatorController = prototype.unitAnimation.animator.runtimeAnimatorController; animator.Play(prototype.unitAnimation.baseLayer.stateHash, 0, prototype.unitAnimation.baseLayer.playbackNormalizedTime); animator.speed = 0.02f; animator.Update(1 / 60f); m_LifeTime = 0.2f; } public void Update() { m_CurTime += Time.deltaTime; if (m_CurTime > m_LifeTime) { GameObject.Destroy(this.gameObject); } } }