Ejemplo n.º 1
0
 public static void WriteObject(object value, ByteBuffer buffer)
 {
     if (value is Vector3)
     {
         buffer.WriteVector3((Vector3)value);
     }
     else if (value is Quaternion)
     {
         buffer.WriteQuaternion((Quaternion)value);
     }
     else if (value is int)
     {
         buffer.WriteInt((int)value);
     }
     else if (value is float)
     {
         buffer.WriteFloat((float)value);
     }
     else if (value is long)
     {
         buffer.WriteLong((long)value);
     }
     else if (value is bool)
     {
         buffer.WriteBool((bool)value);
     }
     else if (value is string)
     {
         buffer.WriteString((string)value);
     }
     else if (value is NetworkBehaviour)
     {
         NetworkBehaviour net = (NetworkBehaviour)value;
         buffer.WriteLong(net == null ? long.MinValue : net.NetworkId);
     }
     else if (value is byte)
     {
         buffer.WriteByte((byte)value);
     }
     else
     {
         byte[] serial = SerialUtility.Serialize(value);
         buffer.WriteByte((byte)serial.Length);
         buffer.WriteBytes(serial);
     }
 }
Ejemplo n.º 2
0
 public void WriteObject(object obj)
 {
     byte[] serial = SerialUtility.Serialize(obj);
     WriteInt(serial.Length);
     WriteBytes(serial);
 }