示例#1
0
		/// <summary>
		/// 从字节数组里读取 Vector3
		/// </summary>
		/// <param name="buffer"> 字节数组 </param>
		/// <param name="offset"> 从字节数组里开始读取的下标, 操作完成后增加 12 </param>
		/// <returns> 读取的 Vector3 值 </returns>
		public static Vector3 ReadVector3FromBuffer(byte[] buffer, ref int offset)
		{
			Vector3 value = new Vector3();
			UnionValue union = new UnionValue();

			union.ReadFloatFrom(buffer, ref offset);
			value.x = union.floatValue;

			union.ReadFloatFrom(buffer, ref offset);
			value.y = union.floatValue;

			union.ReadFloatFrom(buffer, ref offset);
			value.z = union.floatValue;

			return value;
        }
示例#2
0
		/// <summary>
		/// 从字节数组里读取 Quaternion
		/// </summary>
		/// <param name="buffer"> 字节数组 </param>
		/// <param name="offset"> 从字节数组里开始读取的下标, 操作完成后增加 16 </param>
		/// <returns> 读取的 Quaternion 值 </returns>
		public static Quaternion ReadQuaternionFromBuffer(byte[] buffer, ref int offset)
		{
			Quaternion value = new Quaternion();
			UnionValue union = new UnionValue();

			union.ReadFloatFrom(buffer, ref offset);
			value.x = union.floatValue;

			union.ReadFloatFrom(buffer, ref offset);
			value.y = union.floatValue;

			union.ReadFloatFrom(buffer, ref offset);
			value.z = union.floatValue;

			union.ReadFloatFrom(buffer, ref offset);
			value.w = union.floatValue;

			return value;
		}