예제 #1
0
        /// <returns>array or null</returns>
        public static byte[] ReadBytesAndSize(this NetworkReader reader)
        {
            // dont need to ValidateSize here because ReadBytes does it

            return(ReadCountPlusOne(reader, out var count)
                ? reader.ReadBytes(count)
                : null);
        }
예제 #2
0
        // Use checked() to force it to throw OverflowException if data is invalid
        // null support, see NetworkWriter
        public static byte[] ReadBytesAndSize(this NetworkReader reader)
        {
            // count = 0 means the array was null
            // otherwise count -1 is the length of the array
            uint count = reader.ReadPackedUInt32();

            return(count == 0 ? null : reader.ReadBytes(checked ((int)(count - 1u))));
        }
예제 #3
0
 public static Guid ReadGuid(this NetworkReader reader) => new Guid(reader.ReadBytes(16));
예제 #4
0
 public static byte[] ReadBytes(this NetworkReader reader, int count)
 {
     byte[] bytes = new byte[count];
     reader.ReadBytes(bytes, count);
     return(bytes);
 }