UniTask icon indicating copy to clipboard operation
UniTask copied to clipboard

Add TMP_Dropdown extension

Open TORISOUP opened this issue 1 year ago • 2 comments

Added an extension to the Dropdown component of TextMeshPro.

using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using TMPro;
using UnityEngine;

namespace Sandboxes
{
    public class Sandbox: MonoBehaviour
    {
        [SerializeField] private TMP_Dropdown _dropdown;

        async UniTaskVoid Start()
        {
            // IAsyncValueChangedEventHandler
            var changed = await _dropdown
                .GetAsyncValueChangedEventHandler(destroyCancellationToken)
                .OnValueChangedAsync();

            Debug.Log($"Selected index: {changed}");

            // IUniTaskAsyncEnumerable
            _dropdown
                .OnValueChangedAsAsyncEnumerable(destroyCancellationToken)
                .Subscribe(x => { Debug.Log($"Selected index: {x}"); });
        }
    }
}

TORISOUP avatar Jan 06 '25 12:01 TORISOUP

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jul 06 '25 00:07 github-actions[bot]

I am writing to comment because the stale label was automatically assigned by GitHubActions. How about a PR here? You can close it if you don't need it.

TORISOUP avatar Jul 06 '25 07:07 TORISOUP

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jan 04 '26 00:01 github-actions[bot]

Keeping this PR active.

TORISOUP avatar Jan 05 '26 04:01 TORISOUP