You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
907 B
34 lines
907 B
3 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.Events;
|
||
|
using UnityEngine.Serialization;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class ItemDropdown : MonoBehaviour
|
||
|
{
|
||
|
public Text txt;
|
||
|
public Dropdown dropdown;
|
||
|
|
||
|
public void OnInitialized<T>(string str, UnityAction<ItemDropdown> OnChanged)
|
||
|
{
|
||
|
txt.text = $"{str}";
|
||
|
if (OnChanged != null)
|
||
|
OnValueChanged.AddListener(OnChanged);
|
||
|
|
||
|
Util.DropDownList<T>.DropList(dropdown, 0);
|
||
|
|
||
|
dropdown.onValueChanged.AddListener(ToggleChanged);
|
||
|
}
|
||
|
[System.Serializable]
|
||
|
public class ValueChangedEvent : UnityEvent<ItemDropdown> { }
|
||
|
[FormerlySerializedAs("onValueChanged")]
|
||
|
[Space(10)]
|
||
|
[SerializeField]
|
||
|
private ValueChangedEvent OnValueChanged = new ValueChangedEvent();
|
||
|
void ToggleChanged(int value)
|
||
|
{
|
||
|
OnValueChanged.Invoke(this);
|
||
|
}
|
||
|
}
|