Send custom type via Network

Hi guys, :slight_smile:

I made a game and now i want to make a multiplayer part. I have a question about networking, i’m gonna try to explain it clearly :

Situation :

My game gots “Profiles”. “Profile” is a class of my game, a custom type which store many simple variables AND a list of “CustomObject”. BOTH Profile and CustomObject are Serializable.
Offline, i just serialize Profile into a binary file for save profile, and load it when game start.

My online game will be a host/client system. The player which create the game is the server, others players will connect to him (no external server).

Problem :

Online, i want to, when a player is connecting the game, each player connected exchange their Profile object. But it’s a custom style and RPC seems to send only few defines types.

I just start learn Unity Networking, and it seems there’s three solution :

  • I find something about “uLink” which can send custom type with RPC. But i don’t know if the list of “CustomObject” type will be okay (a custom type into a custom type ? can uLink handle that ?) … ?
  • With uLink again or simple RPC send, i can just send every variable of my Profile object and every variable of every CustomObject (but a player can have 50 000 CustomObject if it’s a nolife player…), but it’s a bit fastidious, no ?
  • My two object are serializable. So i can put it into a stream. Is there a solution to send a stream ?

My question :

What is the best solution ? Is a 4th solution exists ? What i have to look into for accomplish what i want ?

Thanks a lot and sorry for my bad english ! :slight_smile:

There are many options to achieve this.

You should be allowed to send a byte[ ] anywhere (no matter if Unity or any other solution).
Convert the needed info to one byte[ ] and send that.

I guess some libraries also allow you to send instances of custom classes. Those will be analyzed at runtime and most likely everything in it will be sent, so there might be some overhead compared to doing it yourself.

Okay thanks, i’m gonna try the byte[ ] solution :slight_smile: