using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace Thousandto.Launcher.ExternalLibs { /// /// 新动作系统的处理 /// [Serializable] public class AnimatorAssetData { [NonSerialized] private Animator _animator; //路径 public string Path; //动作片段 public AnimationClip[] ClipArray; //AnimatorController public RuntimeAnimatorController RuntimeAnimatorController; //编辑器时使用 [NonSerialized] public Transform TheTransform; #region//运行时执行 //卸载处理 public void Unload() { if (ClipArray != null) { for (int i = 0; i < ClipArray.Length; i++) { if (ClipArray[i] != null) { Resources.UnloadAsset(ClipArray[i]); } } } if (RuntimeAnimatorController != null) { Resources.UnloadAsset(RuntimeAnimatorController); } if (_animator != null) { GameObject.Destroy(_animator); } } //设置Animation public void ToAnimator(Transform tran) { _animator = tran.GetComponent(); } #endregion #region//编辑器时执行--打包之前数据准备用 //从Animation中获取信息 public bool FromAnimator(Animator anim) { if (anim != null) { RuntimeAnimatorController = anim.runtimeAnimatorController; if (RuntimeAnimatorController != null) { ClipArray = RuntimeAnimatorController.animationClips; } } return false; } #endregion } }