Why are NetworkWriter and NetworkReader methods not complementary?
Looking at the UNET documentation I find that the NetworkReader has lots of methods like ReadPlane(), ReadQuaternion(), ReadTransform(), etc. Supposedly NetworkReader is supposed to be used with NetworkWriter, but the latter only has WritePackedUInt32() and WritePackedUInt64(). Write() writes GameObjects, so should work with NetworkReader.ReadGameObject() even though the names don't match.
So, my question is: where are all the data that NetworkReader can read supposed to come from since NetworkWriter cannot write them?
There is a method NetworkWriter.WriteBytesAndSize() which writes a byte array, but it seems I would have to use a System.Runtime.Serialization.Formatters.Binary.BinaryFormatter to convert data into such a byte array, unless I want to go with unsafe and potentially unportable pointers.
Answer by kaimikael · Dec 04, 2015 at 12:49 PM
Ah, it seems the problem is that the documentation for NetworkWriter.Write() is incomplete/incorrect. In fact it does not only accept GameObjects, but the following types: Color, Color32, GameObject, Matrix4x4, MessageBase, NetworkHash128, NetworkIdentity, NetworkInstanceId, NetworkSceneId, Plane, Quaternion, Ray, Rect, Transform, Vector2, Vector3, Vector4, bool, byte, char, double, float, int, long, sbyte, short, string, uint, ulong, ushort, and byte[] + int, byte[] + int + int.