forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerializedNetworkedVarExample.cs
More file actions
23 lines (22 loc) · 1.14 KB
/
SerializedNetworkedVarExample.cs
File metadata and controls
23 lines (22 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using MLAPI;
using MLAPI.NetworkedVar;
namespace MLAPI_Examples
{
public class SerializedNetworkedVarExample : NetworkedBehaviour
{
// Default settings, default value
public NetworkedVarInt SerializedNetworkedVarInt = new NetworkedVarInt();
// Default settings, initialization value 5
public NetworkedVarInt SerializedNetworkedVarIntValue = new NetworkedVarInt(5);
// Custom settings
public NetworkedVarInt SerializedNetworkedVarIntSettings = new NetworkedVarInt(new NetworkedVarSettings()
{
SendChannel = "MySendChannel", // The var value will be synced over this channel
ReadPermission = NetworkedVarPermission.Everyone, // The var values will be synced to everyone
ReadPermissionCallback = null, // Only used when using "Custom" read permission
SendTickrate = 2, // The var will sync no more than 2 times per second
WritePermission = NetworkedVarPermission.OwnerOnly, // Only the owner of this object is allowed to change the value
WritePermissionCallback = null // Only used when write permission is "Custom"
});
}
}