Skip to main content

Class FloatPacker

Helps compresses a float into a reduced number of bits

Inheritance​
System.Object
Inherited Members​
Show
Syntax​
public sealed class FloatPacker

Constructors​

FloatPacker(Single, Single)​

Declaration​
public FloatPacker(float max, float lowestPrecision)
Parameters​
TypeNameDescription
System.Singlemax
System.SinglelowestPrecisionlowest precision, actual precision will be caculated from number of bits used

FloatPacker(Single, Int32)​

Declaration​
public FloatPacker(float max, int bitCount)
Parameters​
TypeNameDescription
System.Singlemax
System.Int32bitCount

FloatPacker(Single, Single, Boolean)​

Declaration​
public FloatPacker(float max, float lowestPrecision, bool signed)
Parameters​
TypeNameDescription
System.Singlemax
System.SinglelowestPrecisionlowest precision, actual precision will be caculated from number of bits used
System.Booleansignedif negative values will be allowed or not

FloatPacker(Single, Int32, Boolean)​

Declaration​
public FloatPacker(float max, int bitCount, bool signed)
Parameters​
TypeNameDescription
System.Singlemax
System.Int32bitCount
System.Booleansignedif negative values will be allowed or not

Methods​

Pack(Single)​

Packs a float value into a uint Clamps the value within min/max range

Declaration​
public uint Pack(float value)
Parameters​
TypeNameDescription
System.Singlevalue
Returns​
TypeDescription
System.UInt32

Pack(NetworkWriter, Single)​

Packs and Writes a float value Clamps the value within min/max range

Declaration​
public void Pack(NetworkWriter writer, float value)
Parameters​
TypeNameDescription
Mirage.Serialization.NetworkWriterwriter
System.Singlevalue

PackNoClamp(Single)​

Packs a float value into a uint without clamping it in range

WARNING: only use this method if value is always in range. Out of range values may not be unpacked correctly

Declaration​
public uint PackNoClamp(float value)
Parameters​
TypeNameDescription
System.Singlevalue
Returns​
TypeDescription
System.UInt32

PackNoClamp(NetworkWriter, Single)​

Declaration​
public void PackNoClamp(NetworkWriter writer, float value)
Parameters​
TypeNameDescription
Mirage.Serialization.NetworkWriterwriter
System.Singlevalue

Unpack(UInt32)​

Unpacks uint value to float

Declaration​
public float Unpack(uint value)
Parameters​
TypeNameDescription
System.UInt32value
Returns​
TypeDescription
System.Single

Unpack(NetworkReader)​

Reads and unpacks float value

Declaration​
public float Unpack(NetworkReader reader)
Parameters​
TypeNameDescription
Mirage.Serialization.NetworkReaderreader
Returns​
TypeDescription
System.Single