new UniTask instead of task
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -10,10 +10,10 @@ public class RadialMenuItem : MonoBehaviour
|
||||
[SerializeField]
|
||||
private Button _radialMenuItemPrefab;
|
||||
private Dictionary<RadialMenuActions, RadialMenuActionDescription> _actions;
|
||||
TaskCompletionSource<RadialMenuActions> tcs = new TaskCompletionSource<RadialMenuActions>();
|
||||
UniTaskCompletionSource<RadialMenuActions> tcs = new UniTaskCompletionSource<RadialMenuActions>();
|
||||
|
||||
|
||||
public Task<RadialMenuActions> ShowButtons(RadialMenuItem popupMenu, Dictionary<RadialMenuActions, RadialMenuActionDescription> actions)
|
||||
public UniTask<RadialMenuActions> ShowButtons(RadialMenuItem popupMenu, Dictionary<RadialMenuActions, RadialMenuActionDescription> actions)
|
||||
{
|
||||
|
||||
_actions = actions;
|
||||
@@ -42,13 +42,14 @@ public class RadialMenuItem : MonoBehaviour
|
||||
{
|
||||
b.onClick.AddListener(() =>
|
||||
{
|
||||
tcs.SetResult(_actions.ElementAt(buttonNumber).Key);
|
||||
tcs.TrySetResult(_actions.ElementAt(buttonNumber).Key);
|
||||
Close();
|
||||
});
|
||||
}
|
||||
|
||||
public void CancelAndClose()
|
||||
{
|
||||
tcs.TrySetCanceled();
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user