Exemplo n.º 1
0
        // invoked by unity runtime immediately after the regular "Update()" function.
        internal void UNetUpdate()
        {
            // serialize all the dirty components and send (if any were dirty)
            byte[] payload = OnSerializeAllSafely(false);
            if (payload != null)
            {
                // construct message and send
                UpdateVarsMessage message = new UpdateVarsMessage();
                message.netId   = netId;
                message.payload = payload;

                NetworkServer.SendToReady(gameObject, (short)MsgType.UpdateVars, message);
            }
        }
Exemplo n.º 2
0
        // invoked by unity runtime immediately after the regular "Update()" function.
        internal void UNetUpdate()
        {
            // serialize all the dirty components and send (if any were dirty)
            NetworkWriter writer = new NetworkWriter();

            if (OnSerializeAllSafely(m_NetworkBehaviours, writer, false))
            {
                // construct message and send
                UpdateVarsMessage message = new UpdateVarsMessage();
                message.netId   = netId;
                message.payload = writer.ToArray();

                NetworkServer.SendToReady(gameObject, (short)MsgType.UpdateVars, message);
            }
        }
Exemplo n.º 3
0
        internal static void OnUpdateVarsMessage(NetworkConnection _, UpdateVarsMessage msg)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("ClientScene.OnUpdateVarsMessage " + msg.netId);
            }

            if (NetworkIdentity.spawned.TryGetValue(msg.netId, out NetworkIdentity localObject) && localObject != null)
            {
                localObject.OnUpdateVars(new NetworkReader(msg.payload), false);
            }
            else
            {
                Debug.LogWarning("Did not find target for sync message for " + msg.netId + " . Note: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.");
            }
        }
Exemplo n.º 4
0
        internal static void OnUpdateVarsMessage(UpdateVarsMessage msg)
        {
            if (logger.LogEnabled())
            {
                logger.Log("ClientScene.OnUpdateVarsMessage " + msg.netId);
            }

            if (NetworkIdentity.spawned.TryGetValue(msg.netId, out NetworkIdentity localObject) && localObject != null)
            {
                using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(msg.payload))
                    localObject.OnDeserializeAllSafely(networkReader, false);
            }
            else
            {
                logger.LogWarning("Did not find target for sync message for " + msg.netId + " . Note: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.");
            }
        }
Exemplo n.º 5
0
        static void OnUpdateVarsMessage(NetworkMessage netMsg)
        {
            UpdateVarsMessage message = netMsg.ReadMessage <UpdateVarsMessage>();

            if (LogFilter.Debug)
            {
                Debug.Log("ClientScene::OnUpdateVarsMessage " + message.netId);
            }

            NetworkIdentity localObject;

            if (s_NetworkScene.GetNetworkIdentity(message.netId, out localObject))
            {
                localObject.OnUpdateVars(new NetworkReader(message.payload), false);
            }
            else
            {
                Debug.LogWarning("Did not find target for sync message for " + message.netId + " . Note: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.");
            }
        }
Exemplo n.º 6
0
        // invoked by unity runtime immediately after the regular "Update()" function.
        internal void UNetUpdate()
        {
            // SendToReady sends to all observers. no need to serialize if we
            // don't have any.
            if (observers == null || observers.Count == 0)
            {
                return;
            }

            // serialize all the dirty components and send (if any were dirty)
            byte[] payload = OnSerializeAllSafely(false);
            if (payload != null)
            {
                // construct message and send
                UpdateVarsMessage message = new UpdateVarsMessage();
                message.netId   = netId;
                message.payload = payload;

                NetworkServer.SendToReady(this, (short)MsgType.UpdateVars, message);
            }
        }