Ejemplo n.º 1
0
        static internal void HandleChildTransform(NetworkMessage netMsg)
        {
            NetworkInstanceId netId = netMsg.reader.ReadNetworkId();
            uint childIndex         = netMsg.reader.ReadPackedUInt32();

#if UNITY_EDITOR
            //UnityEditor.NetworkDetailStats.IncrementStat(
            //    UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
            //    MsgType.LocalChildTransform, "16:LocalChildTransform", 1);
#endif

            GameObject foundObj = NetworkServer.FindLocalObject(netId);
            if (foundObj == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Received NetworkTransformChild data for GameObject that doesn't exist");
                }
                return;
            }
            var children = foundObj.GetComponents <NetworkTransformChild>();
            if (children == null || children.Length == 0)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform no children");
                }
                return;
            }
            if (childIndex >= children.Length)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform childIndex invalid");
                }
                return;
            }

            NetworkTransformChild foundSync = children[childIndex];
            if (foundSync == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform null target");
                }
                return;
            }
            if (!foundSync.localPlayerAuthority)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform no localPlayerAuthority");
                }
                return;
            }

            if (!netMsg.conn.clientOwnedObjects.Contains(netId))
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("NetworkTransformChild netId:" + netId + " is not for a valid player");
                }
                return;
            }

            foundSync.UnserializeModeTransform(netMsg.reader, false);
            foundSync.m_LastClientSyncTime = Time.time;

            if (!foundSync.isClient)
            {
                // dedicated server wont interpolate, so snap.
                foundSync.m_Target.localPosition = foundSync.m_TargetSyncPosition;
                foundSync.m_Target.localRotation = foundSync.m_TargetSyncRotation3D;
            }
        }
Ejemplo n.º 2
0
 void OnCRC(NetworkMessage netMsg)
 {
     netMsg.ReadMessage(s_CRCMessage);
     NetworkCRC.Validate(s_CRCMessage.scripts, numChannels);
 }