/// <summary> /// Reads a string from the buffer. /// </summary> /// <returns>The string that has been read from the buffer.</returns> public static string ReadString(this Buffer buffer) { short size = buffer.Read16(); byte[] bytes = buffer.ReadBytes(size); #if UNITY_WINRT && !UNITY_EDITOR return(Encoding.UTF8.GetString(bytes)); #else return(Encoding.Default.GetString(bytes)); #endif }
protected virtual void ReadVariables(Buffer buffer) { short size = buffer.Read16(); for (int i = 0; i < size; i++) { int hashCode = buffer.Read32(); int index = Array.FindIndex(_variables, variable => variable.name.GetHashCode() == hashCode); if (index == -1) { break; } _variables[index].ReadFromStream(buffer); } }
/// <summary> /// Reads a quantized floating point value from the buffer. /// </summary> /// <returns>The original floating point value.</returns> public static float ReadSingleQuantized(this Buffer buffer) { return(buffer.Read16() / 256f); }
public override void ReadFromStream(Buffer buffer) { ReadTransform(buffer, (Flags)buffer.Read16()); }