UnityEngine.Networking.NetworkWriter.WriteBytesAndSize C# (CSharp) Method

WriteBytesAndSize() public method

This writes a 16-bit count and a array of bytes of that length to the stream.

public WriteBytesAndSize ( byte buffer, int count ) : void
buffer byte Array of bytes to write.
count int Number of bytes from the array to write.
return void
        public void WriteBytesAndSize(byte[] buffer, int count)
        {
            if ((buffer == null) || (count == 0))
            {
                this.Write((ushort) 0);
            }
            else if (count > 0xffff)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("NetworkWriter WriteBytesAndSize: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes.");
                }
            }
            else
            {
                this.Write((ushort) count);
                this.m_Buffer.WriteBytes(buffer, (ushort) count);
            }
        }

Usage Example

 public override void Serialize(NetworkWriter writer)
 {
     writer.Write(this.netId);
     if (this.parameters == null)
     {
         writer.WriteBytesAndSize(this.parameters, 0);
     }
     else
     {
         writer.WriteBytesAndSize(this.parameters, this.parameters.Length);
     }
 }
All Usage Examples Of UnityEngine.Networking.NetworkWriter::WriteBytesAndSize