I am trying to send a class which (in the future) will hold a hundred or so variables from my server to client. Classes aren’t supported as RPC parameters, So I am wondering if there is any way to Send them… without having to “unpack” the Class and send each individual variable as a parameter, then Repack them.
1 Answer
1There are 2 solutions to your problem:
- Unpack your data in a string and send that (since you can’t have
argsin RPC functions) - Use (or write) your own Networking solution that does essentially the same
Either way, it’s not a good idea to send allot of data in a single packet.
Hope this helps, Benproductiosn1
Thats unfortunate... Not sure how to pack variables with a string, but I can see that there is no sugar coated answer. Manual Inputs it is. Is there anything wrong with having massive amounts of Parameters in an RPC function... assuming it is only done on Player-Login?(so performance wouldn't matter)
– CuddleMonstertechnically there is nothing wrong. But its not required, you could use .NET serialization to serialize the object to byte[] and deserialize it from byte[] again. as for using an own network solution: before you go there consider testing uLink from MuchDifferent which enables you to continue using what you have or depending on your use case, consider Photon Unity Networking + Photon Cloud / Photon Load Balancing where even custom class serialization can be added
– Dreamora
I found that the best way is to only update the data that has changed. So instead of sending hundreds of variables each time, you only send an update to the variables that change. Usually on level load or when a client loads in you may have to send all this data initially to the server through a series of sent info and then return verification from the server to ensure its been recieved in smaller chunks of data. Would help debugging as well. Then once all the initial data is on the server and forwarded to connected clients, an update function would suffice to update the changed variables.
– Brian_Tsunami