colyseus / colyseus-unity-sdk

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

Use appropriate type in generated C# schema files #139

Closed rthery closed 3 years ago

rthery commented 3 years ago

I've noticed that if I use Colyseus primitive type uint8 for a property in a schema, the generated C# will use uint instead of byte

Probably best to go over all the primitive types supported by Colyseus and make sure that the generated C# use the matching ones, cf. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types

endel commented 3 years ago

Hi @rthery, thank you for noticing and reporting this! You're right, both int8 and uint8 had to be changed to sbyte and byte respectively.

I've just released version 0.14.4 of the unity plugin, and the latest version of @colyseus/schema (1.0.19) is now generating sbyte/byte instead of int8/uint8.

Important: If you happen to upgrade @colyseus/schema without upgrading the Unity client to 0.14.4+ (while using int8/uint8) you're going to see a type conversion error, if that happens to you just upgrade the Unity client (This is the breaking change https://github.com/colyseus/colyseus-unity3d/commit/2d54b25c1b8118191a627556d06aa14313f269f8)