Exemple #1
0
        public byte[] payload; // the parameters for the Cmd function

        public override void Deserialize(NetworkReader reader)
        {
            netId          = reader.ReadPackedUInt32();
            componentIndex = (int)reader.ReadPackedUInt32();
            functionHash   = reader.ReadInt32(); // hash is always 4 full bytes, WritePackedInt would send 1 extra byte here
            payload        = reader.ReadBytesAndSize();
        }
Exemple #2
0
 public override void Deserialize(NetworkReader reader)
 {
     netId          = reader.ReadNetworkId();
     stateHash      = (int)reader.ReadPackedUInt32();
     normalizedTime = reader.ReadSingle();
     parameters     = reader.ReadBytesAndSize();
 }
Exemple #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal void OnDeserializeSafely(NetworkBehaviour comp, NetworkReader reader, bool initialState)
        {
            // extract data length and data safely, untouched by user code
            // -> returns empty array if length is 0, so .Length is always the proper length
            byte[] bytes = reader.ReadBytesAndSize();
            if (LogFilter.Debug)
            {
                Debug.Log("OnDeserializeSafely extracted: " + comp.name + " component=" + comp.GetType() + " sceneId=" + m_SceneId + " length=" + bytes.Length);
            }

            // call OnDeserialize with a temporary reader, so that the
            // original one can't be messed with. we also wrap it in a
            // try-catch block so there's no way to mess up another
            // component's deserialization
            try
            {
                NetworkReader componentReader = new NetworkReader(bytes);
                comp.OnDeserialize(componentReader, initialState);
                if (componentReader.Position != componentReader.Length)
                {
                    Debug.LogWarning("OnDeserialize didn't read the full " + bytes.Length + " bytes for object:" + name + " component=" + comp.GetType() + " sceneId=" + m_SceneId + ". Make sure that OnSerialize and OnDeserialize write/read the same amount of data in all cases.");
                }
            }
            catch (Exception e)
            {
                // show a detailed error and let the user know what went wrong
                Debug.LogError("OnDeserialize failed for: object=" + name + " component=" + comp.GetType() + " sceneId=" + m_SceneId + " length=" + bytes.Length + ". Possible Reasons:\n  * Do " + comp.GetType() + "'s OnSerialize and OnDeserialize calls write the same amount of data(" + bytes.Length + " bytes)? \n  * Was there an exception in " + comp.GetType() + "'s OnSerialize/OnDeserialize code?\n  * Are the server and client the exact same project?\n  * Maybe this OnDeserialize call was meant for another GameObject? The sceneIds can easily get out of sync if the Hierarchy was modified only in the client OR the server. Try rebuilding both.\n\n" + e.ToString());
            }
        }
Exemple #4
0
 public override void Deserialize(NetworkReader reader)
 {
     netId    = reader.ReadNetworkId();
     sceneId  = reader.ReadSceneId();
     position = reader.ReadVector3();
     payload  = reader.ReadBytesAndSize();
 }
Exemple #5
0
 public override void Deserialize(NetworkReader reader)
 {
     netId    = reader.ReadNetworkId();
     assetId  = reader.ReadNetworkHash128();
     position = reader.ReadVector3();
     rotation = reader.ReadQuaternion();
     payload  = reader.ReadBytesAndSize();
 }
Exemple #6
0
 public override void Deserialize(NetworkReader reader)
 {
     netId    = reader.ReadPackedUInt32();
     sceneId  = reader.ReadPackedUInt32();
     position = reader.ReadVector3();
     rotation = reader.ReadQuaternion();
     payload  = reader.ReadBytesAndSize();
 }
Exemple #7
0
 public override void Deserialize(NetworkReader reader)
 {
     netId    = reader.ReadPackedUInt32();
     owner    = reader.ReadBoolean();
     assetId  = reader.ReadGuid();
     position = reader.ReadVector3();
     rotation = reader.ReadQuaternion();
     scale    = reader.ReadVector3();
     payload  = reader.ReadBytesAndSize();
 }
Exemple #8
0
 public override void Deserialize(NetworkReader reader)
 {
     value = reader.ReadBytesAndSize();
 }
Exemple #9
0
 public override void Deserialize(NetworkReader reader)
 {
     netId   = reader.ReadPackedUInt32();
     payload = reader.ReadBytesAndSize();
 }
Exemple #10
0
 public override void Deserialize(NetworkReader reader)
 {
     netId   = reader.ReadNetworkId();
     payload = reader.ReadBytesAndSize();
 }
Exemple #11
0
 public override void Deserialize(NetworkReader reader)
 {
     netId        = reader.ReadNetworkId();
     syncListHash = reader.ReadInt32(); // hash is always 4 full bytes, WritePackedInt would send 1 extra byte here
     payload      = reader.ReadBytesAndSize();
 }
Exemple #12
0
 public override void Deserialize(NetworkReader reader)
 {
     msgData = reader.ReadBytesAndSize();
 }
Exemple #13
0
 public override void Deserialize(NetworkReader reader)
 {
     playerControllerId = (short)reader.ReadPackedUInt32();
     msgData            = reader.ReadBytesAndSize();
 }