I'm using properties and delegates as below.
public event Action<int> OnVariableChanged = delegate { }; public int X { get { return x; } set { int oldValue = x; int newValue = value; //Here you can find out difference x = value; OnVariableChanged.Invoke(value); } }
I'm finding that I need to keep track when a variable is used, for example, is changing in the set block, which doesn't make for an elegant solution.
private void Awake() { OnVariableChanged += OnVariableChangeHandler; } private void OnVariableChangeHandler(int value) { //Do something when variable change }
Could this also be a bug in the underlying libraries?