colyseus / colyseus-unity-sdk

⚔ Colyseus Multiplayer SDK for Unity
https://docs.colyseus.io/getting-started/unity-sdk/
MIT License
378 stars 104 forks source link

Proposal: Allow to send data to the room using a custom Serializable instance #89

Closed endel closed 4 years ago

endel commented 5 years ago

It would be nice to allow using custom Serializable structures to send data to the room.

Example:

[Serializable]
public class InputData
{
    public bool left;
    public bool right;
    public bool top;
    public bool bottom;
}

// e.g. catch user inputs
var input = new InputData();
input.left = true;
input.top = true;

// send the serializable structure
room.Send(input)
ADustyOldMuffin commented 5 years ago

I'd be interested in working on this if it's still open.

endel commented 5 years ago

Hi @ADustyOldMuffin, nice. Feel free to send a PR 🤗

endel commented 4 years ago

Implemented here https://github.com/colyseus/colyseus-unity3d/commit/1954d98aa47caaec2b17d40e6fed2408a189ebb4#diff-71c9fc0505f323e7aa448bcafd028c94R31