New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cant get this to compile in Unity 2022.3.14 #306
Comments
I've never used Unity before so I'm not sure. How would you even get net-6.0/8.0 targeted library to work with Unity? (I believe AlterNats was used in Unity projects and that was targeting net-6, so it must be possible) Did you try adding System.Text.Json DLL as well? |
Yes, I did. That failed because of some weird incompatibility with Unity. I can't recall the error of the top of my head. In the meantime I am using the v1 client, but I would prefer to use the latest and greatest here instead of doing all the threading / task management myself with v1. I am wondering if someone else in the Unity community has managed to make this work. |
I did ask around but haven't heard back yet. One thing I noticed is the target in Unity settings says netstandard 2.1. But we're targeting 6 and 8 at the moment. Having said that the AlterNats project (which we forked from) was targeting net6 as well and they used it for Unity. When I tried I get a System.Runtime version mismatch error. How did you get pass that? |
After doing a bunch of reading, and trying manually installing etc, i gave up and went back to the v1 library instead, and am using that in unity with no problems. i also looked into installing all the code manually, and due to the way the basic code structures, I decided it was way too much work to refactor it all just seems a shame not to be able to use the latest version. not complaining :) |
Sorry about that @adamgoodrich it looks like we need to target netstandard-2.1. I gave it a go trying to see if it's easy enough but seemed like quite a bit of work. We quite consciously decided early on only to target .NET TLS releases maintenance overhead of other targets being one of the reasons. Good news is there seems to be a way as Andrew Laing pointed out: Looks like AlterNats (parent fork) project was using MacigOnion RPC framework in between: I believe this is the general idea:
Please let us know if this is a solution so we can suggest to other Unity devs. |
Just a heads up - I've discussed briefly with @mtmk about Unity support. I'm going to push a PR to the .Net Client here soon that will unblock the latest version of the client to work with I'll link this issue to the PR when I get there in the following weeks. |
Observed behavior
Fails because of dependency on System.Text.Json.
The project is targeted at Android / .Net Standard 2.1. Mono.
I downloaded the .nuget package, unzipped it, and dropped the NATS.Client.Core DLL into the Plugins folder.
Expected behavior
It would be great to use the official library in Unity 3d. Perhaps I am doing something wrong.
Server and client version
I was using the latest Nats.Client.Core.2.0.2
Host environment
No response
Steps to reproduce
Add to unity project, try and use it.
The text was updated successfully, but these errors were encountered: