OnValueChanged only be triggered at the first layer

Issue #260 closed
wavebit created an issue
[Serializable]
public class DataNode
{
    [SerializeField]
    [OnValueChanged("OnNextChanged")]
    public DataNode Next;

    private static int IdCounter;

    public int Id;

    public DataNode()
    {
        Id = IdCounter;
        IdCounter++;
    }

    private void OnNextChanged()
    {
        Test.LogStr = Id + " NextChanged";
    }
}

[ExecuteInEditMode]
public class Test : SerializedMonoBehaviour
{
    public static string LogStr;
    [ShowInInspector, ReadOnly]
    public string Log
    {
        get
        {
            return LogStr;
        }
    }

    [OdinSerialize]
    [NonSerialized]
    public DataNode Head;
}

as2.gif

Comments (2)

  1. Bjarke Elias

    The OnValueChanged attribute has overload that enables that behavior.

    [OnValueChanged("OnNextChanged", IncludeChildren : true)]
    
  2. wavebit reporter

    It is confused if the IncludeChildren is false, I thought it is triggered when property Next is assigned a new value, then it calls itself method OnNextChanged().

  3. Log in to comment