diff --git a/README_CN.md b/README_CN.md index bbf76c7..d875bfd 100644 --- a/README_CN.md +++ b/README_CN.md @@ -18,7 +18,7 @@ UniTask <!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> -## 目录 +## Table of Contents - [入门](#%E5%85%A5%E9%97%A8) - [UniTask 和 AsyncOperation 的基础知识](#unitask-%E5%92%8C-asyncoperation-%E7%9A%84%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86) @@ -43,7 +43,7 @@ UniTask - [UniTaskSynchronizationContext](#unitasksynchronizationcontext) - [API 文档](#api-%E6%96%87%E6%A1%A3) - [UPM 包](#upm-%E5%8C%85) -- [通过 git URL 安装](#%E9%80%9A%E8%BF%87-git-url-%E5%AE%89%E8%A3%85) + - [通过 git URL 安装](#%E9%80%9A%E8%BF%87-git-url-%E5%AE%89%E8%A3%85) - [关于 .NET Core](#%E5%85%B3%E4%BA%8E-net-core) - [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/TextMeshPro/TextMeshProAsyncExtensions.Dropdown.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/TextMeshPro/TextMeshProAsyncExtensions.Dropdown.cs new file mode 100644 index 0000000..dc89b1f --- /dev/null +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/TextMeshPro/TextMeshProAsyncExtensions.Dropdown.cs @@ -0,0 +1,43 @@ +#if UNITASK_TEXTMESHPRO_SUPPORT + +using System; +using System.Threading; +using TMPro; + +namespace Cysharp.Threading.Tasks +{ + public static partial class TextMeshProAsyncExtensions + { + public static IAsyncValueChangedEventHandler<int> GetAsyncValueChangedEventHandler(this TMP_Dropdown dropdown) + { + return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy(), false); + } + + public static IAsyncValueChangedEventHandler<int> GetAsyncValueChangedEventHandler(this TMP_Dropdown dropdown, CancellationToken cancellationToken) + { + return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, cancellationToken, false); + } + + public static UniTask<int> OnValueChangedAsync(this TMP_Dropdown dropdown) + { + return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); + } + + public static UniTask<int> OnValueChangedAsync(this TMP_Dropdown dropdown, CancellationToken cancellationToken) + { + return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, cancellationToken, true).OnInvokeAsync(); + } + + public static IUniTaskAsyncEnumerable<int> OnValueChangedAsAsyncEnumerable(this TMP_Dropdown dropdown) + { + return new UnityEventHandlerAsyncEnumerable<int>(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy()); + } + + public static IUniTaskAsyncEnumerable<int> OnValueChangedAsAsyncEnumerable(this TMP_Dropdown dropdown, CancellationToken cancellationToken) + { + return new UnityEventHandlerAsyncEnumerable<int>(dropdown.onValueChanged, cancellationToken); + } + } +} + +#endif \ No newline at end of file diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/TextMeshPro/TextMeshProAsyncExtensions.Dropdown.cs.meta b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/TextMeshPro/TextMeshProAsyncExtensions.Dropdown.cs.meta new file mode 100644 index 0000000..ae3739a --- /dev/null +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/TextMeshPro/TextMeshProAsyncExtensions.Dropdown.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b858132b120c42b99cac55fd06dd32d3 +timeCreated: 1736165018 \ No newline at end of file