用一个异步方法来播放一个动画,正常情况是:动画播放结束时,异步方法宣告结束。那如果我提前取消这个异步任务,那在这个异步方法里面,我要怎么停止播放呢?! 一、播放animation动画的异步实现 1、用play播放动画片段 2、await一段时间,等动画播放结束 3、用stop停止动画播放 二、两种实现方式 实现原理: 定义了两个结束的事件(或者Task): (1)第一个是播放时长到点了 (2)第二个是用户取消了异步任务 (3)用whenAny等待 public static async UniTask<bool> PlayAnim(Animation Anim, float startTime, float endTime, float speed, CancellationToken ctk) { Debug.Log($"当前Time.timeScale = {Time.timeScale}"); float t = (endTime - startTime) * Time.timeScale; Debug.Log($"动画的时长为:{t}秒");...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with Await
Contact Await, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack