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


C# UnityEngine.BitStream类代码示例

本文整理汇总了C#中UnityEngine.BitStream的典型用法代码示例。如果您正苦于以下问题:C# BitStream类的具体用法?C# BitStream怎么用?C# BitStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DeSerialize

 // assumes a reading stream
 public void DeSerialize( BitStream stream )
 {
     int x = 0;
     int y = 0;
     stream.Serialize( ref x );
     stream.Serialize( ref y );
     this.x = x;
     this.y = y;
 }
开发者ID:pmlamotte,项目名称:2Pac,代码行数:10,代码来源:IntVector2.cs

示例2: Serialize

		public static bool Serialize (BitStream stream, bool boolean)
		// Serialize a bool to a BitStream
		{
			int integer = boolean ? 1 : 0;

			stream.Serialize (ref integer);

			return integer == 1;
		}
开发者ID:NotYours180,项目名称:UnityHacks,代码行数:9,代码来源:Utility.Network.cs

示例3: OnSerializeNetworkView

        void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
        {
            float ping = 1.0F;

            if (stream.isWriting) {
                stream.Serialize(ref ping);
            } else {
                transitTime = (Network.time - info.timestamp)*1000;
                stream.Serialize(ref ping);
            }
        }
开发者ID:Geor23,项目名称:Planets,代码行数:11,代码来源:Statistics.cs

示例4: OnSerializeNetworkView

 public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     if(stream.isReading)
     {
         mRefreshRecSum++;
     }
     else
     {
         mRefreshSentSum++;
     }
     parent.SingleEndpoint_OnSerialize(stream, ConnectedUser);
 }
开发者ID:apiotrow,项目名称:webrtcnetwork,代码行数:12,代码来源:SingleEndpointConnection.cs

示例5: OnSerializeNetworkView

        void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
        {
            int count = packets.Count;

            if (stream.isWriting)
            {
                stream.Serialize(ref count);

                while (packets.Count > 0)
                {
                    VoiceChatPacket packet = packets.Dequeue();
                    stream.WritePacket(packet);

                    // If this packet is the same size as the sample size, we can return it
                    if (packet.Data.Length == VoiceChatSettings.Instance.SampleSize)
                    {
                        VoiceChatBytePool.Instance.Return(packet.Data);
                    }
                }
            }
            else
            {
                if (Network.isServer)
                {
                    stream.Serialize(ref count);

                    for (int i = 0; i < count; ++i)
                    {
                        packets.Enqueue(stream.ReadPacket());

                        if (Network.connections.Length < 2)
                        {
                            packets.Dequeue();
                        }
                    }
                }
                else
                {
                    stream.Serialize(ref count);

                    for (int i = 0; i < count; ++i)
                    {
                        var packet = stream.ReadPacket();

                        if (player != null)
                        {
                            player.OnNewSample(packet);
                        }
                    }
                }
            }
        }
开发者ID:Ramzawulf,项目名称:unityassets,代码行数:52,代码来源:VoiceChatNetworkProxy.cs

示例6: OnSerializeNetworkView

 protected void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo msg)
 {
     var time = 0;
     //mID = (int) ID;
     if (stream.isWriting)
     {
         stream.Serialize(ref DoubleMissileTime);
         //stream.Serialize(ref mID);
     }
     else
     {
         stream.Serialize(ref time);
         DoubleMissileTime = time;
         //stream.Serialize(ref mID);
         //ID = (PlayerIndex) mID;
     }
 }
开发者ID:sundayliu,项目名称:HelloWorld-unity3d,代码行数:17,代码来源:AircraftController.cs

示例7: OnSerializeNetworkView

        private void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
            // Serialize the position and color
            if (stream.isWriting) {
                Color color = _renderer.material.color;

                stream.Serialize(ref color.r);
                stream.Serialize(ref color.g);
                stream.Serialize(ref color.b);
                stream.Serialize(ref color.a);
            } else {
                Color color = Color.white;

                stream.Serialize(ref color.r);
                stream.Serialize(ref color.g);
                stream.Serialize(ref color.b);
                stream.Serialize(ref color.a);

                _renderer.material.color = color;
            }

            _transformInterpolation.OnSerializeNetworkView(stream, info, _transform.position, _transform.rotation);
        }
开发者ID:mbhuet,项目名称:MastersProject,代码行数:22,代码来源:TestActor.cs

示例8: OnSerializeNetworkView

        public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info, Vector3 position, Quaternion rotation) {
            // Always send transform (depending on reliability of the network view)
            if (stream.isWriting) {
                // When receiving, buffer the information
                stream.Serialize(ref position);
                stream.Serialize(ref rotation);
            } else {
                // Receive latest state information
                position = Vector3.zero;
                rotation = Quaternion.identity;
                stream.Serialize(ref position);
                stream.Serialize(ref rotation);

                // Shift buffer contents, oldest data erased, 18 becomes 19, ... , 0 becomes 1
                for (int i = _bufferedStates.Length - 1; i >= 1; i--) {
                    _bufferedStates[i] = _bufferedStates[i - 1];
                }

                // Save currect received state as 0 in the buffer, safe to overwrite after shifting
                State state;
                state.Timestamp = info.timestamp;
                state.Position = position;
                state.Rotation = rotation;
                _bufferedStates[0] = state;

                // Increment state count but never exceed buffer size
                _timestampCount = Mathf.Min(_timestampCount + 1, _bufferedStates.Length);

                // Check integrity, lowest numbered state in the buffer is newest and so on
                for (int i = 0; i < _timestampCount - 1; i++) {
                    if (_bufferedStates[i].Timestamp < _bufferedStates[i + 1].Timestamp)
                        Debug.Log("State inconsistent");
                }

                _isReceivedFirstInfo = true;
                // Debug.Log("stamp: " + info.Timestamp + "my time: " + Network.time + "delta: " + (Network.time - info.Timestamp));
            }
        }
开发者ID:mbhuet,项目名称:MastersProject,代码行数:38,代码来源:NetworkTransformInterpolation.cs

示例9: INTERNAL_CALL_Serializen

 private static extern void INTERNAL_CALL_Serializen(BitStream self, ref NetworkViewID viewID);
开发者ID:randomize,项目名称:VimConfig,代码行数:1,代码来源:BitStream.cs

示例10: Serialize

 // assumes a writing stream
 public void Serialize( BitStream stream )
 {
     location.Serialize( stream );
     offset.Serialize( stream );
 }
开发者ID:pmlamotte,项目名称:2Pac,代码行数:6,代码来源:BoardLocation.cs

示例11: Serialize

 // assumes a writing stream
 public void Serialize( BitStream stream )
 {
     int x = this.x;
     int y = this.y;
     stream.Serialize( ref x );
     stream.Serialize( ref y );
 }
开发者ID:pmlamotte,项目名称:2Pac,代码行数:8,代码来源:IntVector2.cs

示例12: OnSerializeNetworkView

		void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
		{
			LogTime("OnSerializeNetworkView");
			CallScriptMethod("OnSerializeNetworkView");
		}
开发者ID:vivence,项目名称:GhostStudio,代码行数:5,代码来源:TestMonobehavior.cs

示例13: OnSerializeNetworkView

 /// <summary>Used to customize synchronization of variables in a script watched by a network view.</summary>
 public virtual void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { }
开发者ID:songotony,项目名称:RType-Client,代码行数:2,代码来源:TypedMonoBehaviour.cs

示例14: OnSerializeNetworkView

 public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     var vessel = GetComponent<Vessel>();
     if (stream.isWriting)
     {
         var eccentricity = (float)vessel.orbit.eccentricity;
         var semiMajorAxis = (float)vessel.orbit.semiMajorAxis;
         var inclination = (float)vessel.orbit.inclination;
         var lan = (float)vessel.orbit.LAN;
         var argumentOfPeriapsis = (float)vessel.orbit.argumentOfPeriapsis;
         var meanAnomalyAtEpoch = (float)vessel.orbit.meanAnomalyAtEpoch;
         var epoch = (float)vessel.orbit.epoch;
         var bodyId = FlightGlobals.Bodies.IndexOf(vessel.orbit.referenceBody);
         stream.Serialize(ref eccentricity, float.Epsilon);
         stream.Serialize(ref semiMajorAxis, float.Epsilon);
         stream.Serialize(ref inclination, float.Epsilon);
         stream.Serialize(ref lan, float.Epsilon);
         stream.Serialize(ref argumentOfPeriapsis, float.Epsilon);
         stream.Serialize(ref meanAnomalyAtEpoch, float.Epsilon);
         stream.Serialize(ref epoch, float.Epsilon);
         stream.Serialize(ref bodyId);
     }
     else
     {
         float eccentricity = 0f, semiMajorAxis = 0f, inclination = 0f, lan = 0f, argumentOfPeriapsis = 0f;
         var meanAnomalyAtEpoch = 0f;
         var epoch = 0f;
         var bodyId = 0;
         stream.Serialize(ref eccentricity, float.Epsilon);
         stream.Serialize(ref semiMajorAxis, float.Epsilon);
         stream.Serialize(ref inclination, float.Epsilon);
         stream.Serialize(ref lan, float.Epsilon);
         stream.Serialize(ref argumentOfPeriapsis, float.Epsilon);
         stream.Serialize(ref meanAnomalyAtEpoch, float.Epsilon);
         stream.Serialize(ref epoch, float.Epsilon);
         stream.Serialize(ref bodyId);
         var newOrbit = new Orbit(inclination, eccentricity, semiMajorAxis, lan, argumentOfPeriapsis, meanAnomalyAtEpoch, epoch, FlightGlobals.Bodies[bodyId]);
         newOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
         if (vessel.packed)
         {
             if (vessel.Landed)
                 vessel.Landed = false;
             if (vessel.Splashed)
                 vessel.Splashed = false;
             vessel.orbit.UpdateFromOrbitAtUT(newOrbit, Planetarium.GetUniversalTime(), newOrbit.referenceBody);
         }
         else
         {
             vessel.SetPosition(newOrbit.pos);
             vessel.SetWorldVelocity(newOrbit.vel);
         }
     }
 }
开发者ID:Arduinology,项目名称:Khylib,代码行数:53,代码来源:Kestrel.cs

示例15: OnSerializeNetworkView

 void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     InvokeInManagers ("OnSerializeNetworkView", stream, info);
 }
开发者ID:mstevenson,项目名称:UnityManagerWrangler,代码行数:4,代码来源:ManagerWrangler.cs


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