Hide
OnArraySizeChanged
Caution
Deprecated. Use OnValueChanged instead.
Important
Enable SaintsEditor before using

OnValueChanged can not detect if an array/list is changed in size. OnArraySizeChanged attribute will call a callback for that.

Using it together with OnValueChanged to get all changing notification for an array/list.

Parameters:

  • string callback: the callback function when the size changed.
  • Allow Multiple: No
using SaintsField; // namespace for OnValueChanged using SaintsField.Playa; // namespace for OnArraySizeChanged [Serializable] public class MyClass // generic class change is also detectable { public string unique; } [OnValueChanged(nameof(ValueChanged))] // optional [OnArraySizeChanged(nameof(SizeChanged))] public MyClass[] myClasses; public void ValueChanged(MyClass myClass, int index) => Debug.Log(
quot;OnValueChanged:
{myClass.unique} at {index}"); // if you do not care about values, just omit the parameters public void SizeChanged(IReadOnlyList<MyClass> myClassNewValues) => Debug.Log(
quot;OnArraySizeChanged
{myClassNewValues.Count}: {string.Join("; ", myClassNewValues.Select(each => each?.unique))}");