Switched to 1d array CollectSyncedData
This commit is contained in:
@@ -128,26 +128,25 @@ public class TestBall : SyncedObject
|
||||
Debug.Log($"({nameof(TestBall)}) Up button pressed, jumped up at {GetProgress()} to {amountUp}.");
|
||||
}
|
||||
|
||||
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType)
|
||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
if (eventType == NetworkEventType.FullSync
|
||||
|| eventType == NetworkEventType.FullSyncForced)
|
||||
{
|
||||
Debug.Log($"({nameof(TestBall)}) Sending sync data at progress {GetProgress()} and amountUp {amountUp}.");
|
||||
data[index++] = BitConverter.GetBytes(amountUp);
|
||||
data[index++] = BitConverter.GetBytes(GetProgress());
|
||||
ByteUtils.Append(amountUp, data, ref index);
|
||||
ByteUtils.Append(GetProgress(), data, ref index);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
if (eventType == NetworkEventType.FullSync
|
||||
|| eventType == NetworkEventType.FullSyncForced)
|
||||
{
|
||||
amountUp = BitConverter.ToSingle(data, index);
|
||||
SetProgress(BitConverter.ToSingle(data, index + 4));
|
||||
amountUp = ByteUtils.ReadFloat(data, ref index);
|
||||
SetProgress(ByteUtils.ReadFloat(data, ref index));
|
||||
//Debug.Log($"({nameof(TestBall)}) Received sync event, synced to progress {GetProgress()} and amountUp {amountUp}.");
|
||||
index += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user