當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。