Restore Sync Properties

Sync Properties are stored on the SocketWeaver game servers. They persist even when players are disconnected. SyncPropertyAgent will fetch its Sync Properties in the Start() method. The On Ready Event is invoked when a Sync Property finished fetching its value from the SocketWeaver game server and is ready to be used.

Example

1: Implement the event listener method

int defaultHP = 100;
int currentHP = 0;
‚Äč
public void OnHPReady()
{
int remoteHP = syncPropertyAgent.GetPropertyWithName("hp").GetIntValue();
if (networkId.IsMine())
{
int version = syncPropertyAgent.GetPropertyWithName("hp").version;
if(version != 0)
{
currentHP = remoteHP;
}
else
{
syncPropertyAgent.Modify("hp", defaultHP);
currentHP = defaultHP;
}
}
else
{
currentHP = remoteHP;
}
}

2: Add a listener to the On Ready Event