UnityEngine.Networking.NetworkTransformChild.UnserializeModeTransform C# (CSharp) Method

UnserializeModeTransform() private method

private UnserializeModeTransform ( NetworkReader reader, bool initialState ) : void
reader NetworkReader
initialState bool
return void
        private void UnserializeModeTransform(NetworkReader reader, bool initialState)
        {
            if (base.hasAuthority)
            {
                reader.ReadVector3();
                if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                {
                    NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
                }
            }
            else if (base.isServer && (this.m_ClientMoveCallback3D != null))
            {
                Vector3 position = reader.ReadVector3();
                Vector3 zero = Vector3.zero;
                Quaternion identity = Quaternion.identity;
                if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                {
                    identity = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
                }
                if (this.m_ClientMoveCallback3D(ref position, ref zero, ref identity))
                {
                    this.m_TargetSyncPosition = position;
                    if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                    {
                        this.m_TargetSyncRotation3D = identity;
                    }
                }
            }
            else
            {
                this.m_TargetSyncPosition = reader.ReadVector3();
                if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                {
                    this.m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
                }
            }
        }

Usage Example

        static internal void HandleChildTransform(NetworkMessage netMsg)
        {
            NetworkInstanceId netId = netMsg.reader.ReadNetworkId();
            uint childIndex         = netMsg.reader.ReadPackedUInt32();

#if UNITY_EDITOR
            Profiler.IncrementStatIncoming(MsgType.LocalChildTransform, "16:LocalChildTransform");
#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;
            }
        }
All Usage Examples Of UnityEngine.Networking.NetworkTransformChild::UnserializeModeTransform