Can I see how many bytes are being sent by a particular SyncVar variable?

I’ve been experimenting with sending my information in two ways.

  1. The first way is to create a struct
    and put the [SyncVar] tag on it.
  2. The second way is to convert the ‘would-be’ struct into a string and [SyncVar] on a string. Basically a Vector3 would turn into something like, “1.2343 5.2634 9.23456” which I would then rebuild by manually parsing. Realistically there would be more than just a Vector3, but hopefully you get the idea

Really, all I want to know is which way actually sends less information, but I can’t find a way to do this. The Unity profiler doesn’t have the actual bytes, and NetworkServer.GetStatsIn/Out doesn’t do anything. I’m also running it on my localhost and I don’t know how to capture that information with programs like Wireshark.

Question: How can I measure the amount of bytes being sent by a SyncVar, OR Would my ghetto string method be smaller than syncing actual Vector3/Quaternion/floats/doubles/etc since it’s all on a single variable?

While I haven’t technically found an answer on how to measure the amount of information being sent, I’ve decided to use a simple approach suggested by Nisovin to just measure the size of objects being synced by their fields and estimate using that.


I don’t actually know the answer, but I can make a guess. Floats take up 4 bytes each, and a Vector3 has three floats, for a total of 12 bytes. Strings take up two bytes per character (I believe), which means your example string, with 21 characters, takes up 42 bytes. Unless the Vector3 has much higher overhead, I would expect it to be more efficient.