Changing array reference does not trigger onVariableChange
__라요
Changing the reference to an synced array with something like
var tmp = (int[]) MyList.Clone();
tmp[0] = someValue;
MyList = tmp;
RequestSerialization();
doesn't trigger onVariableChange(OnFieldChange in UdonSharp) on remote players.
Log In
ShingenPizza
well, strictly speaking this isn't a bug.
changing the reference doesn't matter, as it's just a local address, that won't be shared with remote players anyway.
i'm not sure if it warrants a separate report, but...
the real bug-ish is that the FieldChangeCallback fires ONLY if the reference changes, not the contents.
while this isn't a problem locally, because you can always set the new contents in a new array and assign it to the class's field (and thus change the reference, triggering the callback),
for remotes, as it turns out, if the synced array is of the same size as the old one, they skip creating a new array, and just copy the contents over. this means the reference is not changing, and thus the callback does not fire.
as a workaround i suggest creating a synced integer that you increment every time you change the synced array, and a local boolean. when the integer or array itself changes you set the boolean to true, and in
OnDeserialization
you execute whatever the callback would do if it worked on-contents-changed.