Skip to content

Instantly share code, notes, and snippets.

@Denchyaknow
Last active November 17, 2024 02:48
Show Gist options
  • Save Denchyaknow/ca44c187dd00379fa56f3ed05f4e910d to your computer and use it in GitHub Desktop.
Save Denchyaknow/ca44c187dd00379fa56f3ed05f4e910d to your computer and use it in GitHub Desktop.
NetCode Type Sizing Chart
Type Byte Size Optimization Note
bool 1 No optimization; always 1 byte.
byte 1 No optimization; always 1 byte.
sbyte 1 No optimization; always 1 byte.
short 2 No optimization; always 2 bytes.
ushort 2 No optimization; always 2 bytes.
int 4 May be compressed if the value fits into a smaller range. Some serializers (e.g., protobuf, or certain Unity networking tools) convert to short or byte dynamically.
uint 4 Similar to int; may compress to smaller sizes.
long 8 No known automatic compression; manually optimize if values can fit into smaller types.
ulong 8 Same as long; use smaller types manually if needed.
float 4 No optimization; always 4 bytes.
double 8 No automatic conversion; consider using float for smaller precision.
char 2 Unicode characters; no optimization.
string Variable Serialized length + UTF-8 encoded bytes. Length affects network size.
Vector2 8 Two floats; consider fixed-point math if smaller precision suffices.
Vector3 12 Three floats; same suggestion as above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment