当前位置: 首页>>代码示例>>C#>>正文


C# NetworkReader.ReadVector3方法代码示例

本文整理汇总了C#中NetworkReader.ReadVector3方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkReader.ReadVector3方法的具体用法?C# NetworkReader.ReadVector3怎么用?C# NetworkReader.ReadVector3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetworkReader的用法示例。


在下文中一共展示了NetworkReader.ReadVector3方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

 public override void Deserialize(NetworkReader reader)
 {
     this.netId = reader.ReadNetworkId();
     this.sceneId = reader.ReadSceneId();
     this.position = reader.ReadVector3();
     this.payload = reader.ReadBytesAndSize();
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:7,代码来源:ObjectSpawnSceneMessage.cs

示例2: OnDeserialize

 public override void OnDeserialize(NetworkReader reader, bool initialState)
 {
     /*
         Interpolate: pass reader as parameter to fbxobj
     */
     fbxObj.gameObject.transform.position = reader.ReadVector3();
 }
开发者ID:menezesgam,项目名称:poc_vr,代码行数:7,代码来源:RpcManager.cs

示例3: OnDeserialize

    private CharacterState serverLastState; //SERVER: Store last state

    #endregion Fields

    #region Methods

    /// <summary>
    /// All Clients: Deserialize the state from network
    /// </summary>
    /// <param name="reader"></param>
    /// <param name="initialState"></param>
    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        CharacterState state = new CharacterState();

        state.state    = reader.ReadInt32();
        state.position = reader.ReadVector3();
        state.rotation = reader.ReadQuaternion();

        //Client: Received a new state for the local player, treat it as an ACK and do reconciliation
        if (isLocalPlayer) {
            SendMessage("ServerState", state, SendMessageOptions.DontRequireReceiver);
        } else {
            //Other Clients: Received a state, treat it like a new position snapshot from authority
            if (initialState)
            {
                //Others Clients: First state, just snap to new position
                transform.position = state.position;
                transform.rotation = state.rotation;
            }
            else if (networkInterpolation != null)
            {
                //Others Clients: Interpolate between received positions
                networkInterpolation.ReceiveState(state);
            }
        }
    }
开发者ID:atrakeur,项目名称:unity-unet-authoritative-networking,代码行数:37,代码来源:CharacterNetworkSync.cs

示例4: Deserialize

 public override void Deserialize(NetworkReader reader)
 {
     base.Deserialize(reader);
     int count = reader.ReadInt32();
     Polyline = new List<Vector3>(count);
     for(int i=0; i < count; i++)
         Polyline.Add(reader.ReadVector3());
 }
开发者ID:yuta0023,项目名称:demo,代码行数:8,代码来源:EditorMessages.cs

示例5: Deserialize

 public override void Deserialize(NetworkReader reader)
 {
     this.netId = reader.ReadNetworkId();
     this.assetId = reader.ReadNetworkHash128();
     this.position = reader.ReadVector3();
     this.payload = reader.ReadBytesAndSize();
     uint num = 0x10;
     if ((reader.Length - reader.Position) >= num)
     {
         this.rotation = reader.ReadQuaternion();
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:12,代码来源:ObjectSpawnMessage.cs

示例6: OnDeserialize

    //writing to the stream
    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        //base.OnDeserialize(reader, initialState);
        realPosition = reader.ReadVector3();
        realRotation = reader.ReadQuaternion();


        /* 
        Debug.Log("sadddsdadss");

        if (stream.isWriting)
        {//this is your information you will send over the network
            sendPosition = this.transform.position;
            sendRotation = this.transform.rotation;
            stream.Serialize(ref sendPosition);//im pretty sure you have to use ref here, check that
            stream.Serialize(ref sendRotation);//same with the ref here...
        }
        else if (stream.isReading)
        {//this is the information you will recieve over the network
            stream.Serialize(ref realPosition);//Vector3 position
            stream.Serialize(ref realRotation);//Quaternion postion
        }
        */
    }
开发者ID:EatWithMe,项目名称:alfaSquad,代码行数:25,代码来源:NetSmoothMove.cs

示例7: Deserialize

 public override void Deserialize(NetworkReader reader)
 {
     m_id = reader.ReadNetworkId();
     m_parentId = reader.ReadNetworkId();
     m_childId = reader.ReadInt32();
     m_position = reader.ReadVector3();
     m_payload = reader.ReadBytesAndSize();
 }
开发者ID:bpeake13,项目名称:UnityChildSpawning,代码行数:8,代码来源:ChildSpawnMessage.cs

示例8: UnserializeModeCharacterController

 private void UnserializeModeCharacterController(NetworkReader reader, bool initialState)
 {
     if ((UnityEngine.Object) this.m_CharacterController == (UnityEngine.Object) null)
     return;
       this.m_TargetSyncPosition = reader.ReadVector3();
       this.m_FixedPosDiff = (this.m_TargetSyncPosition - this.transform.position) / this.GetNetworkSendInterval() * Time.fixedDeltaTime;
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
     this.m_TargetSyncRotation3D = this.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
       if (this.isServer && !this.isClient)
       {
     this.transform.position = this.m_TargetSyncPosition;
     this.transform.rotation = this.m_TargetSyncRotation3D;
       }
       else if ((double) this.GetNetworkSendInterval() == 0.0)
       {
     this.transform.position = this.m_TargetSyncPosition;
     if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
       return;
     this.transform.rotation = this.m_TargetSyncRotation3D;
       }
       else
       {
     if ((double) (this.transform.position - this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
       this.transform.position = this.m_TargetSyncPosition;
     if ((double) this.interpolateRotation == 0.0)
       this.transform.rotation = this.m_TargetSyncRotation3D;
     if ((double) this.m_InterpolateMovement == 0.0)
       this.transform.position = this.m_TargetSyncPosition;
     if (!initialState)
       return;
     this.transform.rotation = this.m_TargetSyncRotation3D;
       }
 }
开发者ID:Kitabalef,项目名称:Unet-Decompiles,代码行数:33,代码来源:NetworkTransform.cs

示例9: UnserializeModeTransform

 private void UnserializeModeTransform(NetworkReader reader, bool initialState)
 {
   if (this.hasAuthority)
   {
     reader.ReadVector3();
     if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
       return;
     NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
   }
   else if (this.isServer && this.m_ClientMoveCallback3D != null)
   {
     Vector3 position = reader.ReadVector3();
     Vector3 zero = Vector3.zero;
     Quaternion rotation = Quaternion.identity;
     if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
       rotation = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
     if (!this.m_ClientMoveCallback3D(ref position, ref zero, ref rotation))
       return;
     this.m_TargetSyncPosition = position;
     if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
       return;
     this.m_TargetSyncRotation3D = rotation;
   }
   else
   {
     this.m_TargetSyncPosition = reader.ReadVector3();
     if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
       return;
     this.m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
   }
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:31,代码来源:NetworkTransformChild.cs

示例10: UnserializeMode3D

 private void UnserializeMode3D(NetworkReader reader, bool initialState)
 {
   if (this.hasAuthority)
   {
     reader.ReadVector3();
     reader.ReadVector3();
     if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
       NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
     if (!this.syncSpin)
       return;
     NetworkTransform.UnserializeSpin3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
   }
   else
   {
     if (this.isServer && this.m_ClientMoveCallback3D != null)
     {
       Vector3 position = reader.ReadVector3();
       Vector3 velocity = reader.ReadVector3();
       Quaternion rotation = Quaternion.identity;
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         rotation = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
       if (!this.m_ClientMoveCallback3D(ref position, ref velocity, ref rotation))
         return;
       this.m_TargetSyncPosition = position;
       this.m_TargetSyncVelocity = velocity;
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         this.m_TargetSyncRotation3D = rotation;
     }
     else
     {
       this.m_TargetSyncPosition = reader.ReadVector3();
       this.m_TargetSyncVelocity = reader.ReadVector3();
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         this.m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
     }
     if (this.syncSpin)
       this.m_TargetSyncAngularVelocity3D = NetworkTransform.UnserializeSpin3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
     if ((UnityEngine.Object) this.m_RigidBody3D == (UnityEngine.Object) null)
       return;
     if (this.isServer && !this.isClient)
     {
       this.m_RigidBody3D.MovePosition(this.m_TargetSyncPosition);
       this.m_RigidBody3D.MoveRotation(this.m_TargetSyncRotation3D);
       this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity;
     }
     else if ((double) this.GetNetworkSendInterval() == 0.0)
     {
       this.m_RigidBody3D.MovePosition(this.m_TargetSyncPosition);
       this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity;
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         this.m_RigidBody3D.MoveRotation(this.m_TargetSyncRotation3D);
       if (!this.syncSpin)
         return;
       this.m_RigidBody3D.angularVelocity = this.m_TargetSyncAngularVelocity3D;
     }
     else
     {
       if ((double) (this.m_RigidBody3D.position - this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
       {
         this.m_RigidBody3D.position = this.m_TargetSyncPosition;
         this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity;
       }
       if ((double) this.interpolateRotation == 0.0 && this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
       {
         this.m_RigidBody3D.rotation = this.m_TargetSyncRotation3D;
         if (this.syncSpin)
           this.m_RigidBody3D.angularVelocity = this.m_TargetSyncAngularVelocity3D;
       }
       if ((double) this.m_InterpolateMovement == 0.0)
         this.m_RigidBody3D.position = this.m_TargetSyncPosition;
       if (!initialState || this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
         return;
       this.m_RigidBody3D.rotation = this.m_TargetSyncRotation3D;
     }
   }
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:76,代码来源:NetworkTransform.cs

示例11: UnserializeModeCharacterController

 private void UnserializeModeCharacterController(NetworkReader reader, bool initialState)
 {
   if (this.hasAuthority)
   {
     reader.ReadVector3();
     if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
       return;
     NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
   }
   else
   {
     if (this.isServer && this.m_ClientMoveCallback3D != null)
     {
       Vector3 position = reader.ReadVector3();
       Quaternion rotation = Quaternion.identity;
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         rotation = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
       if ((UnityEngine.Object) this.m_CharacterController == (UnityEngine.Object) null)
         return;
       Vector3 velocity = this.m_CharacterController.velocity;
       if (!this.m_ClientMoveCallback3D(ref position, ref velocity, ref rotation))
         return;
       this.m_TargetSyncPosition = position;
       this.m_TargetSyncVelocity = velocity;
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         this.m_TargetSyncRotation3D = rotation;
     }
     else
     {
       this.m_TargetSyncPosition = reader.ReadVector3();
       if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         this.m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
     }
     if ((UnityEngine.Object) this.m_CharacterController == (UnityEngine.Object) null)
       return;
     this.m_FixedPosDiff = (this.m_TargetSyncPosition - this.transform.position) / this.GetNetworkSendInterval() * Time.fixedDeltaTime;
     if (this.isServer && !this.isClient)
     {
       this.transform.position = this.m_TargetSyncPosition;
       this.transform.rotation = this.m_TargetSyncRotation3D;
     }
     else if ((double) this.GetNetworkSendInterval() == 0.0)
     {
       this.transform.position = this.m_TargetSyncPosition;
       if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
         return;
       this.transform.rotation = this.m_TargetSyncRotation3D;
     }
     else
     {
       if ((double) (this.transform.position - this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
         this.transform.position = this.m_TargetSyncPosition;
       if ((double) this.interpolateRotation == 0.0 && this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
         this.transform.rotation = this.m_TargetSyncRotation3D;
       if ((double) this.m_InterpolateMovement == 0.0)
         this.transform.position = this.m_TargetSyncPosition;
       if (!initialState || this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
         return;
       this.transform.rotation = this.m_TargetSyncRotation3D;
     }
   }
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:62,代码来源:NetworkTransform.cs

示例12: Deserialize

            public override void Deserialize(NetworkReader reader)
            {
                name = reader.ReadString();

                var isNull = reader.ReadBoolean();
                if (isNull){
                    value = null;
                    return;
                }

                var typeName = reader.ReadString();
                var t = System.Type.GetType(typeName);

                if (t == typeof(string)){
                    value = reader.ReadString();
                    return;
                }
                if (t == typeof(bool)){
                    value = reader.ReadBoolean();
                    return;
                }
                if (t == typeof(int)){
                    value = reader.ReadInt32();
                    return;
                }
                if (t == typeof(float)){
                    value = reader.ReadSingle();
                    return;
                }
                if (t == typeof(Color)){
                    value = reader.ReadColor();
                    return;
                }
                if (t == typeof(Vector2)){
                    value = reader.ReadVector2();
                    return;
                }
                if (t == typeof(Vector3)){
                    value = reader.ReadVector3();
                    return;
                }
                if (t == typeof(Vector4)){
                    value = reader.ReadVector4();
                    return;
                }
                if (t == typeof(Quaternion)){
                    value = reader.ReadQuaternion();
                    return;
                }
                if (t == typeof(GameObject)){
                    value = reader.ReadGameObject();
                    return;
                }
                if (typeof(Component).RTIsAssignableFrom(t)){
                    var go = reader.ReadGameObject();
                    if (go != null){
                        value = go.GetComponent(t);
                    }
                    return;
                }
            }
开发者ID:nemish,项目名称:cubematters,代码行数:61,代码来源:SyncBlackboard.cs

示例13: UnserializeVelocity3D

 public static Vector3 UnserializeVelocity3D(NetworkReader reader, NetworkTransform.CompressionSyncMode compression)
 {
   return reader.ReadVector3();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:4,代码来源:NetworkTransform.cs

示例14: UnserializeModeTransform

 private void UnserializeModeTransform(NetworkReader reader, bool initialState)
 {
     this.transform.position = reader.ReadVector3();
       if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
     return;
       this.transform.rotation = this.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
 }
开发者ID:Kitabalef,项目名称:Unet-Decompiles,代码行数:7,代码来源:NetworkTransform.cs

示例15: OnDeserialize

    // OnDeserialize is called on the client-side when data is received from the server
    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {               
        var rtt = NetworkClient.allClients[0].GetRTT();

        var serverFrame = reader.ReadPackedUInt32();
        var serverPosition = reader.ReadVector3();
        var serverRotation = reader.ReadQuaternion();
        var serverForce = reader.ReadVector3();
        var checksum = reader.ReadPackedUInt32();

        // Create an EntityState from the data given by the server
        var serverState = new EntityState
            {
                position = serverPosition,
                rotation = serverRotation,
                force = serverForce
            };

        // Drop the packet if we simulate packet drop
        if (NetworkDebugSettings.SimulatedPacketDropPct > 0)
        {
            var result = Random.Range(0, 100);
            if (result <= NetworkDebugSettings.SimulatedPacketDropPct)
            {
                Debug.LogWarning("Simulated packet drop, server frame: " + serverFrame);
                return;
            }
        }

        // Perform checksum and drop bad packets
        if (checksum != Checksum(serverState))
        {
            Debug.LogError("PACKET CRC ERROR");
            return;
        }

        // Discard packets that are out of date.
        if (serverFrame < _lastServerFrameForPlayer)
        {
            Debug.LogError("Discarding old packet");
            return; // discard
        }

        if (NetworkDebugSettings.SimulatedLatency == 0)
        {
            AcceptUpdateFromServer(rtt, serverFrame, serverState);
        }
        else
        {
            StartCoroutine(AcceptUpdateFromServerCoro(rtt, serverFrame, serverState, NetworkDebugSettings.SimulatedLatency/1000f));
        }
    }
开发者ID:Avatarchik,项目名称:RealTimeNetworkExample,代码行数:53,代码来源:Player.cs


注:本文中的NetworkReader.ReadVector3方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。