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.
31 lines
839 B
31 lines
839 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.Serialization;
|
|
using UnityEngine.UI;
|
|
|
|
public class ItemToggle : MonoBehaviour
|
|
{
|
|
public Text txt;
|
|
public Toggle toggle;
|
|
|
|
public void OnInitialized(string str, UnityAction<ItemToggle> OnChanged)
|
|
{
|
|
txt.text = $"{str}";
|
|
if (OnChanged != null)
|
|
OnValueChanged.AddListener(OnChanged);
|
|
|
|
toggle.onValueChanged.AddListener(ToggleChanged);
|
|
}
|
|
[System.Serializable]
|
|
public class ValueChangedEvent : UnityEvent<ItemToggle> { }
|
|
[FormerlySerializedAs("onValueChanged")]
|
|
[Space(10)]
|
|
[SerializeField]
|
|
private ValueChangedEvent OnValueChanged = new ValueChangedEvent();
|
|
void ToggleChanged(bool isOn)
|
|
{
|
|
OnValueChanged.Invoke(this);
|
|
}
|
|
}
|
|
|