I am using Unity Transport and the WritePacked and ReadPacked functions from DataStreamWriter/Reader. These take a NetworkCompressionModel.
I have been unable to find documentation or samples for this, so I tried it out. Here’s what I’m doing:
On both client and server, I create a NetworkCompressionModel by simply doing:
new NetworkCompressionModel(Allocator.Persistent);
I store this in component data alongside the NetworkDriver and Pipelines.
I then pass that as a ref through my code until finally passing it to the DataStreamWriter/Reader, which does not take the parameter as a ref.
This is “working” and it’s doing “stuff”.
At first, I had one mismatch where I was writing a value packed, but not reading it packed, and I would get an error trying to read beyond the end of the DataStreamReader’s buffer.
After seeing that everything was working properly, I did some calculations by checking DataStreamWriter.Length after filling a big packet that has tons of packed floats. I did this once with WritePackedFloat calls, and then again with just WriteFloat calls. To my surprise, the packet was much BIGGER when using the WritePacked calls!
Why would this be? Having set this up a bit blind without documentation or samples, I would expect that I’m not doing it right, yet. Anyone else using WritePacked and NetworkCompressionModel?