I’m trying to implement a feature that detects a change in the value of another field object reference.
For example, there is an A object, and the B object contains A. The A object is notified by OnValidate when the field of the A object has changed. At this time. Is there any way that “B” can detect the change of “A”?
This feature is only required in the Editor and does not include code in Runtime.
public class A : ScriptableObject
{
[SerializeField]
public string team;
private void OnValidate()
{
Debug.Log($"My team name has been changed to {team}.");
}
}
public class B : ScriptableObject
{
[SerializeField]
public A a;
private void OnValidate()
{
Debug.Log($"A changed.");
}
// How can I detect changes to A and call this functions?
private void OnATeamChanged()
{
Debug.Log($"A's team name has been changed to {a.team}.");
}
private void OnADestroyed()
{
Debug.Log($"A is missing.");
}
}