一、Unity 模型使用“Animation”播放动画
1、指定动画:Animation
2、取消自动播放:Play Automatically
3、Ctrl+6打开Animation可视化界面
二、Unity 模型Animator 改为 Animation
将“Animator”改为“Animation”:在“Project”里选中模型——在“Inspector”点击“Rig”——“Animation Type”选择“Legacy”——点击“Apply”即可
三、Untiy Start 里播放动画
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationOperate : MonoBehaviour
{
private Animation _Animation;
// Start is called before the first frame update
void Start()
{
// 动画
_Animation = gameObject.GetComponent<Animation>();
// 播放默认动画
_Animation.clip = _Animation.GetClip(Movement.ToString());
_Animation.playAutomatically = true;
}
// Update is called once per frame
void Update()
{
}
}
四、Unity 动画倒播
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationOperate : MonoBehaviour
{
// 动画状态机
private Animation _Animation;
// 动画状态
private AnimationState _AnimationState;
// 动画名称
private string _AnimationName = "Take 001";
// Start is called before the first frame update
void Start()
{
// 动画状态机
_Animation = gameObject.GetComponent<Animation>();
// 动画播放模式
_Animation.wrapMode = WrapMode.Once;
// 动画状态
_AnimationState = _Animation[_AnimationName];
// 这里把动画的当前帧变为该动画的最后一帧
_AnimationState.time = _Animation.clip.length;
// 速度调为-1
_AnimationState.speed = -1f;
// 播放
_Animation.Play();
}
// Update is called once per frame
void Update()
{
// 判断动画播放完成
if (_Animation.IsPlaying(_AnimationName))
{
// 释放脚本
Destroy(this);
}
}
}