Bitstream.Serialze in C#

This is a method in my MonoBehaviour class:

void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
	int s = 999;
	print("sending 999");
	stream.Serialize(s);
}

Unity is treating the int (and all the other types I tried) as a bool, and then complaining about an invalid argument. Does anybody know how I need to call Seriaize in C#?

This happens if you don’t pass the variables with the ref keyword. The topmost error in the console should say this.

So you need to write:

stream.Serialize(ref s);

Thank you. I was trying to use .