Customizing Behavior
There are settings and attributes unique to SyncTypes which allow various ways of customizing your SyncType.
SyncTypeSettings
// Custom settings are optional.
// This is an example of declaring a SyncVar without custom settings.
private readonly SyncVar<int> _myInt = new();
// Each SyncType has a different constructor to take settings.
// Here is an example for SyncVars. This will demonstrate how to use
// the unreliable channel for SyncVars, and send the value upon any change.
// There are many different ways to create SyncTypeSettings; you can even
// make a const settings and initialize with that!
private readonly SyncVar<int> _myInt = new(new SyncTypeSettings(0f, Channel.Unreliable));// This example shows in Awake but this code
// can be used literally anywhere.
private void Awake()
{
// You can change all settings at once.
_myInt.UpdateSettings(new SyncTypeSettings(....);
// Or update only specific things, such as SendRate.
// Change send rate to once per second.
_myInt.UpdateSendRate(1f);
}Showing in the inspector
Last updated