Hi guys.
I just want to ask if Unity has any events when the user clicks these buttons? If not - maybe anybody knows the way how to hook up these actions?
Hi guys.
I just want to ask if Unity has any events when the user clicks these buttons? If not - maybe anybody knows the way how to hook up these actions?
Could do it like this…
using System.Collections.Generic;
using UnityEngine;
public class TestListChangeEvent : MonoBehaviour
{
private int previousCount = 0;
public List<int> ints = new List<int>();
private void OnValidate()
{
if (ints.Count != previousCount)
{
Debug.Log("change detected: " + ((ints.Count > previousCount) ? "more" : "less") + " items now.");
previousCount = ints.Count;
}
}
}
Edit: To avoid an initial event, could serialize previousCount, or default that to -1, and in OnValidate if it’s -1 just set it to the current count and return instead of checking.
I love you! (like an old friend, not like I want to have sex with you) Thanks for the help