Cysharp / MagicOnion

Unified Realtime/API framework for .NET platform and Unity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MagicOnion.Generated.cs fails to compile in unity

wmqKevin opened this issue · comments

Every time I declare a function with multiple parameters, an error is reported below:
image
FormatterNotRegisteredException: MagicOnion.DynamicArgumentTuple`2[[Shared.MessagePackObjects.JoinRequest, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[Shared.MessagePackObjects.TransformRequest, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] is not registered in resolver.
I don't know is that I didn't generate MagicOnion.Generated.cs. But the MagicOnion.Generated.cs I generated through MagicOnion.MSBuild.Tasks fails to compile every time. Like these images
image
image

How can I solve this problem?

MSBuild.Task is no longer supported in MagicOnion 5.x.
MessagePack Formatter error may be due to the Resolver not registered.

https://github.com/Cysharp/MagicOnion/blob/release/5.x/README.md#messagepack-for-c-1

MSBuild.Task is no longer supported in MagicOnion 5.x. MessagePack Formatter error may be due to the Resolver not registered.

https://github.com/Cysharp/MagicOnion/blob/release/5.x/README.md#messagepack-for-c-1

Thank you @mayuki

the problem was solved after I manually added it. However, when I declare a function, if there are multiple parameters, MagicOnion will generate the corresponding DynamicArgumentTuple, but I haven't found a way to automatically generate the corresponding Formatter. Can it be generated automatically?

If code is generated by generator, it will automatically generate the corresponding Formatter for the argument.
https://github.com/Cysharp/MagicOnion/blob/release/5.x/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs#L148

If code is generated by generator, it will automatically generate the corresponding Formatter for the argument. https://github.com/Cysharp/MagicOnion/blob/release/5.x/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs#L148

Thank you @mayuki
I looked at the content of "ChatApp.Shared.csproj" and solved the problem, but a new problem has emerged - -.
When my Server serializes UnityEngine.Vector3, a similar FormatterNotRegisteredException error occurs. I tried to register it in the Resolver using the MagicOnionResolver in Unity, but it seems to have no effect.
image
Is there any way to register Unity's data structures on the server side, or do I need to define new structures myself?

On the server side, need to install/use the MessagePack.UnityShims package.
https://github.com/MessagePack-CSharp/MessagePack-CSharp?tab=readme-ov-file#unity-support

On the server side, need to install/use the MessagePack.UnityShims package. https://github.com/MessagePack-CSharp/MessagePack-CSharp?tab=readme-ov-file#unity-support

Thank you!
It works!