I have this code:
[Command]
void Cmd_DeleteFromList (int _indx) {
print ("1) syncLC: " + syncLC.cardSyncList.Count);
if (!hasAuthority)
return;
print ("2) syncLC: " + syncLC.cardSyncList.Count + " - _indx: " + _indx);
syncLC.cardSyncList.RemoveAt (_indx); <<< ERROR here
print ("3) syncLC: " + syncLC.cardSyncList.Count);
}
I get the following output from the Print’s:
1) syncLC: 52
2) syncLC: 52 - _indx: 51
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
I have checked and the record at index 51, the last one as it starts at 0, is there prior to execute this code. It cast the error when i run the .RemoveAt code. After the out of range is cased it has removed the last record (_indx = 51) from the SyncListString but still cast the error. print #3 is never executed.
This happens both when i test only with one client and with multiple clients. It also happens when i use _indx = 10 (or any other number).
It never cast a SyncList .RemoveAt according to my callback: " SyncListString.Operation_op" as it does the add’s. …still the last record in the SyncList is removed. Hmmm. it feels the I do the RemoveAt locally but doesn’t execute in the SyncList framework?
I do not understand what i do wrong?