继续重构调整(UI)
- 引入 UniTask 和异步版本的 UIModule - 调整 Runtime/UIBase 和 Presentation 下的脚本命名空间到 SepCore.UI - 将原来的 5 层 UI 迁移到异步实现 - 规范各层的 UI 脚本命名
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cysharp.Threading.Tasks.Triggers
|
||||
{
|
||||
public static partial class AsyncTriggerExtensions
|
||||
{
|
||||
public static AsyncStartTrigger GetAsyncStartTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncStartTrigger>(gameObject);
|
||||
}
|
||||
|
||||
public static AsyncStartTrigger GetAsyncStartTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncStartTrigger();
|
||||
}
|
||||
}
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class AsyncStartTrigger : AsyncTriggerBase<AsyncUnit>
|
||||
{
|
||||
bool called;
|
||||
|
||||
void Start()
|
||||
{
|
||||
called = true;
|
||||
RaiseEvent(AsyncUnit.Default);
|
||||
}
|
||||
|
||||
public UniTask StartAsync()
|
||||
{
|
||||
if (called) return UniTask.CompletedTask;
|
||||
|
||||
return ((IAsyncOneShotTrigger)new AsyncTriggerHandler<AsyncUnit>(this, true)).OneShotAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user