OnValueChangedΒΆ

Detects a value change and executes a callback. Keep in mind that the event is detected only when the value is changed from the inspector. If you want a runtime event, you should probably use an event/delegate and subscribe to it.

Note

If you want to use it on fields that are nested inside serialized structs or classes you need to use the AllowNesting attribute.

public class NaughtyComponent : MonoBehaviour
{
    [OnValueChanged("OnValueChangedCallback")]
    public int myInt;

    private void OnValueChangedCallback()
    {
        Debug.Log(myInt);
    }
}