Files
MinFt/Client/Assets/Scripts/UIExtend/Animation/AnimationExtensions.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

59 lines
1.6 KiB
C#

using System.Collections.Generic;
using System.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
/// <summary>
/// Animation 扩展方法
/// </summary>
public static class AnimationExtensions
{
/// <summary>
/// 播放单个动画并等待完成
/// </summary>
public static async Task PlayAndWaitAsync(this Animation animation, string clipName)
{
if (string.IsNullOrEmpty(clipName) || animation == null)
{
return;
}
var clip = animation[clipName];
if (clip == null)
{
Debug.LogWarning($"Animation clip '{clipName}' not found on {animation.gameObject.name}");
return;
}
animation.Play(clipName);
await Awaiters.Seconds(clip.length);
}
/// <summary>
/// 播放多个动画并等待全部完成 (类似 Task.WhenAll)
/// </summary>
public static async Task PlayAllAndWaitAsync(this Animation animation, params string[] clipNames)
{
if (animation == null || clipNames == null || clipNames.Length == 0)
return;
foreach (var name in clipNames)
{
await animation.PlayAndWaitAsync(name);
}
}
/// <summary>
/// 播放多个动画并等待全部完成 (类似 Task.WhenAll)
/// </summary>
public static async Task PlayAllAndWaitAsync(this Animation animation, IEnumerable<string> clipNames)
{
if (animation == null || clipNames == null)
return;
foreach (var name in clipNames)
{
await animation.PlayAndWaitAsync(name);
}
}
}