ProjectDDD/Assets/Plugins/AllIn1VfxToolkit/Demo & Assets/Demo/Scripts/All1DemoDropdownScroller.cs
2025-07-08 19:46:31 +09:00

32 lines
896 B
C#

using UnityEngine;
using UnityEngine.UI;
namespace AllIn1VfxToolkit.Demo.Scripts
{
[RequireComponent(typeof(Dropdown))]
public class All1DemoDropdownScroller : MonoBehaviour
{
[SerializeField] private int dropdownElementCount;
[SerializeField] private KeyCode nextDropdownElementKey = KeyCode.M;
private Dropdown dropdown;
private void Start()
{
dropdown = GetComponent<Dropdown>();
}
private void Update()
{
if(Input.GetKeyDown(nextDropdownElementKey)) NextDropdownElements();
}
private void NextDropdownElements()
{
int nextValue = dropdown.value + 1;
if(nextValue < 0) nextValue = dropdownElementCount - 1;
if(nextValue >= dropdownElementCount) nextValue = 0;
dropdown.value = nextValue;
}
}
}