Esempio n. 1
0
 /// <summary>
 /// Writes an array of bytes to the buffer.
 /// </summary>
 /// <param name="bytes">The array of bytes that should be written to the buffer.</param>
 public static void Write(this Buffer buffer, byte[] bytes)
 {
     for (int i = 0; i < bytes.Length; i++)
     {
         buffer.Append(bytes[i]);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Writes an array of bytes to the buffer.
 /// </summary>
 /// <param name="bytes">The array of bytes that should be written to the buffer.</param>
 /// <param name="offset">Read offset in bytes where the bytes should be read from.</param>
 /// <param name="length">The number of bytes to be read from the input buffer.</param>
 public static void Write(this Buffer buffer, byte[] bytes, int offset, int length)
 {
     for (int i = offset; i < length; i++)
     {
         buffer.Append(bytes[i]);
     }
 }
Esempio n. 3
0
        public static void WriteNativeList <T>(this Buffer buffer, NativeList <T> list, Allocator allocator) where T : struct
        {
            buffer.Write((int)allocator);

            if (allocator == Allocator.Invalid)
            {
                return;
            }

            buffer.Write(list.Length);

            int elemSize;

            unsafe
            {
                elemSize = UnsafeUtility.SizeOf <T>();
            }

            NativeArray <byte> bytes = list.AsArray().Reinterpret <byte>(elemSize);

            buffer.Append(bytes);
        }
Esempio n. 4
0
 /// <summary>
 /// Writes a single byte (8-bit value) to the buffer.
 /// </summary>
 /// <param name="value">The byte that should be written to the buffer.</param>
 public static void Write(this Buffer buffer, byte value)
 {
     buffer.Append(value);
 }