public void SyncState() { if (!hasAuthority) { return; } // Send update to all clients if (isServer) { UMsgSyncState msg = new UMsgSyncState(this); if (isClient) { UNetworkManager.singleton.SendMessageToAllClientsExceptLocal(msg); } else { UNetworkManager.singleton.SendMessageToAllClients(msg); } } if (isClient && !isServer) { UMsgSyncState msg = new UMsgSyncState(this); UNetworkManager.singleton.SendMessageToServer(msg); } }
internal void HandleBehaviourSyncMessage(UMsgSyncState msg) { UNetworkBehaviour beh = cachedBehaviours[msg.netComponentId]; NetBuffer reader = new NetBuffer(); reader.Data = msg.data; beh.Deserialize(reader, false); }
private void ClientHandleUMsgSyncState(Message m) { if (isServer) { return; } UMsgSyncState msg = m as UMsgSyncState; UNetworkIdentity iden = networkObjects[msg.targetNetID]; iden.HandleBehaviourSyncMessage(msg); }
private void ServerHandleUMsgSyncState(Message m) { UMsgSyncState msg = m as UMsgSyncState; UNetworkIdentity iden; if (networkObjects.TryGetValue(msg.targetNetID, out iden)) { iden.HandleBehaviourSyncMessage(msg); // Resend this update to other clients except local if present serverObject.SendToAllExceptOneClient(msg.sourceClient, msg, NetDeliveryMethod.ReliableOrdered); } }
public void ForceSyncServerStateToClients() { if (isServer) { UMsgSyncState msg = new UMsgSyncState(this); if (isClient) { UNetworkManager.singleton.SendMessageToAllClientsExceptLocal(msg); } else { UNetworkManager.singleton.SendMessageToAllClients(msg); } } }