当前位置:网站首页>unity 动画结束 后处理事件
unity 动画结束 后处理事件
2022-08-07 10:01:00 【云小川】
1.GetCurrentAnimatorStateInfo方法判断动画播放
public class Test : MonoBehaviour
{
private Animator animator;
private AnimatorStateInfo info;
void Awake()
{
animator = GetComponent<Animator>();
}
void Update()
{
info = animator.GetCurrentAnimatorStateInfo(0);
if (info.normalizedTime >= 1) // 判断动画播放结束normalizedTime的值为0~1,0为开始,1为结束。
{
gameObject.SetActive(false);
}
}
}2.在动画结束帧后面加个动画事件
3.获取动画时长
/// <summary>
/// 获得animator下某个动画片段的时长方法
/// </summary>
/// <param animator="animator">Animator组件</param>
/// <param name="name">要获得的动画片段名字</param>
/// <returns></returns>
public float GetAnimatorLength(Animator animator ,string name)
{
//动画片段时间长度
float length = 0;
AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
Debug.Log(clips.Length);
foreach (AnimationClip clip in clips)
{
Debug.Log(clip.name);
if (clip.name.Equals(name))
{
length = clip.length;
break;
}
}
return length;
}
边栏推荐
- 求平均数解决溢出问题的方法
- China's mobile phones continue to innovate, and the full screen goes further, leading mobile phone innovation
- Some summary about common build tools
- On how to improve the ability of learning
- 进程的调度
- 数据库之存储
- 使用scanf()时,可能出现的错误
- 装了这几个IDEA插件,基本上一站式开发了!
- VPC5021电流模式 PWM 控制器 3uA 超低启动电流
- 解决Redis、MySQL缓存双写不一致问题
猜你喜欢

New in ABP 6.0.0-rc.1

For high-performance, ultra-large-scale model training, this combination "debuts"

thinkphp 6.x 任意文件写入漏洞

自定义推送铃声插件遇到的问题

为了高性能、超大规模的模型训练,这个组合“出道”了

你知道12306 是如何支撑百万 QPS 的?

岛屿的最大面积

Product "free gift" + premium investment, Sanofi fired the first shot of bottom-hunting China's biotech assets

How does Apache, the world's largest open source foundation, work?

GPT - 3 combination DALL e., 60 seconds to get the game set and original animation!After the net friend to see: want to play this game
随机推荐
Redis只能做缓存?太out了!
微突发丢包的艺术
强化学习入门 第四讲 时间差分法(TD方法)
[Bit band operation to register assignment] GPIO multiplexing mode initialization based on ADuCM4050
The principle and source code of redis - basic introduction
字符设备主设备号和次设备号的分配
The 900-page mathematical paper proves that the rotating black hole will not explode, Chengtong Yau: The first major breakthrough in general relativity in more than 30 years...
【.NET6+Modbus】Modbus TCP协议解析、仿真环境以及基于.NET实现基础通信
企业内容建站系统 ModStartCMS v4.5.0 后台登录改版,登录安全增强
UGUI系列-实现进度条效果(Unity3D)
你知道12306 是如何支撑百万 QPS 的?
Some summary about common build tools
360 Enterprise Security Cloud debuts at the 2022 Global Digital Economy Conference to consolidate the digital foundation of small, medium and micro enterprises
UGUI系列-文字实现进度等待、进度加载、进程等待演示动画
Flask Framework - Class Based Views
LVS+Keepalived high availability cluster deployment
Material Design
100天精通Andriod逆向——第1天:ADB原理及其常用命令
uniapp本地插件列表为空的问题
STM32 UART串口printf函数应用及浮点打印代码空间节省 (HAL)