Skip to content

Commit 2c20cf1

Browse files
committed
add TMP_Dropdown extension
1 parent f213ff4 commit 2c20cf1

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#if UNITASK_TEXTMESHPRO_SUPPORT
2+
3+
using System;
4+
using System.Threading;
5+
using TMPro;
6+
7+
namespace Cysharp.Threading.Tasks
8+
{
9+
public static partial class TextMeshProAsyncExtensions
10+
{
11+
public static IAsyncValueChangedEventHandler<int> GetAsyncValueChangedEventHandler(this TMP_Dropdown dropdown)
12+
{
13+
return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy(), false);
14+
}
15+
16+
public static IAsyncValueChangedEventHandler<int> GetAsyncValueChangedEventHandler(this TMP_Dropdown dropdown, CancellationToken cancellationToken)
17+
{
18+
return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, cancellationToken, false);
19+
}
20+
21+
public static UniTask<int> OnValueChangedAsync(this TMP_Dropdown dropdown)
22+
{
23+
return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy(), true).OnInvokeAsync();
24+
}
25+
26+
public static UniTask<int> OnValueChangedAsync(this TMP_Dropdown dropdown, CancellationToken cancellationToken)
27+
{
28+
return new AsyncUnityEventHandler<int>(dropdown.onValueChanged, cancellationToken, true).OnInvokeAsync();
29+
}
30+
31+
public static IUniTaskAsyncEnumerable<int> OnValueChangedAsAsyncEnumerable(this TMP_Dropdown dropdown)
32+
{
33+
return new UnityEventHandlerAsyncEnumerable<int>(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy());
34+
}
35+
36+
public static IUniTaskAsyncEnumerable<int> OnValueChangedAsAsyncEnumerable(this TMP_Dropdown dropdown, CancellationToken cancellationToken)
37+
{
38+
return new UnityEventHandlerAsyncEnumerable<int>(dropdown.onValueChanged, cancellationToken);
39+
}
40+
}
41+
}
42+
43+
#endif

src/UniTask/Assets/Plugins/UniTask/Runtime/External/TextMeshPro/TextMeshProAsyncExtensions.Dropdown.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)