public class AttributesSync : CommunicationBridgeUIDpublic class MyAttributesSyncClass : AttributesSync
{
[SynchronizableField]
public string MyString;
}public class MessageAll : AttributesSync
{
public void SendRpc()
{
// Invoke method by name. alternatively, we can call by index.
BroadcastRemoteMethod(nameof(Message), "Hello, world!");
}
// the SynchronizableMethod attribute marks methods available for remote invocation.
[SynchronizableMethod]
private void Message(string msg)
{
Debug.Log(msg);
}
}public class PlayAudioSync : AttributesSync
{
// reference to AudioSource.
public AudioSource AudioSource;
// public method that we call in event or from external scripts
public void Play()
{
// Invoke method with index 0 on all clients including sender.
BroadcastRemoteMethod();
}
// We define our synced method here.
// As we only define one we know this one have index 0.
[SynchronizableMethod]
private void PlayRemote()
{
AudioSource.Play();
}
}public class Message : AttributesSync
{
// id is index of user
public void SendMessageToUser(ushort id, string message)
{
// Invoke method by index.
InvokeRemoteMethod(0, id, message);
}
public void SendMessageToUser(ushort[] ids, string message)
{
// Invoke method by index.
InvokeRemoteMethod(0, ids, message);
}
// Because this is the first method defined, we know its index is 0. The next one would have index of 1.
[SynchronizableMethod]
private void Message(string msg)
{
Debug.Log(msg);
}
}| BroadcastRemoteMethod(Int32, Object) | Calls method with the SynchronizableMethod attribute on evey client including sender with given parameters. |
| BroadcastRemoteMethod(String, Object) | Calls method with the SynchronizableMethod attribute on evey client including sender with given parameters. with given parameters. |
| Commit | Send all changes to all users. |
| ForceSync | Force all fields to be synced as if they where changed. |
| GetMethodAttributeId | Get index of method with the SynchronizableMethod attribute by name. |
| GetMethodAttributeName | Get name of method with the SynchronizableMethod attribute by index. |
| InvokeRemoteMethod(Int32, UserId, Object) | Invoke a method with the SynchronizableMethod attribute on target user with given parameters. |
| InvokeRemoteMethod(Int32, ListUInt16, Object) | Invoke a method with the SynchronizableMethod attribute on target users with given parameters. |
| InvokeRemoteMethod(Int32, UInt16, Object) | Invoke a method with the SynchronizableMethod attribute on target user with given parameters. |
| InvokeRemoteMethod(String, UserId, Object) | Invoke a method with the SynchronizableMethod attribute on target user with given parameters. |
| InvokeRemoteMethod(String, ListUInt16, Object) | Invoke a method with the SynchronizableMethod attribute on target users with given parameters. |
| InvokeRemoteMethod(String, UInt16, Object) | Invoke a method with the SynchronizableMethod attribute on target user with given parameters. |
| LateUpdate | Handle changes fields. |
| Register | (Overrides CommunicationBridgeUIDRegister) |
| Serialize |
Write changes to a ITransportStreamWriter processor.
(Overrides CommunicationBridgeUIDSerialize(ITransportStreamWriter, Byte, Boolean)) |
| UncommittedFields | Check if there is any uncommitted changes to any fields. |
| Unserialize |
Read changes from a ITransportStreamReader processor.
(Overrides CommunicationBridgeUIDUnserialize(ITransportStreamReader, Byte, UInt32)) |
| LocalMethodBehavior | Chose how local methods behave when sending. |
| Reliability | Chose how to send data. Reliable or Unreliable. |