UnityEngine.Networking.NetBuffer.WriteBytes C# (CSharp) Method

WriteBytes() public method

public WriteBytes ( byte buffer, ushort count ) : void
buffer byte
count ushort
return void
        public void WriteBytes(byte[] buffer, ushort count)
        {
            this.WriteCheckForSpace(count);
            if (count == buffer.Length)
            {
                buffer.CopyTo(this.m_Buffer, (int) this.m_Pos);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    this.m_Buffer[(int) ((IntPtr) (this.m_Pos + i))] = buffer[i];
                }
            }
            this.m_Pos += count;
        }

Usage Example

Example #1
0
        public void Write(string value)
        {
            if (value == null)
            {
                m_Buffer.WriteByte2(0, 0);
                return;
            }
            int byteCount = s_Encoding.GetByteCount(value);

            if (byteCount >= 32768)
            {
                throw new IndexOutOfRangeException("Serialize(string) too long: " + value.Length);
            }
            Write((ushort)byteCount);
            int bytes = s_Encoding.GetBytes(value, 0, value.Length, s_StringWriteBuffer, 0);

            m_Buffer.WriteBytes(s_StringWriteBuffer, (ushort)bytes);
        }
All Usage Examples Of UnityEngine.Networking.NetBuffer::WriteBytes