I want to use AdminApiClient in CloudCode (config.Dependencies.AddSingleton(AdminApiClient.Create());)
But i realized its only avaliable in Unity.Services.CloudCode.Core.Admin which is not avaliable in CloudCode.Core (0.0.1).
So i updated it with NuGet to version (Com.Unity.Services.CloudCode.Core to 0.0.2). The code compiles and works properly when deployed but when generating bindings with updated module im having following error and no code is being generated (only assembly definition file is generated).
The error is not printed in console nor in deployment window, only in .ccmr file in inspector.
I also would like to point out another uncomfortable fact that:
When generating bindings no overloaded constructors are being transferred to generated code which makes it cumbersome to use transferred data structures - workaround is to write partial class that has overloaded constructors
This is not likely to happen, as static methods/classes are much harder to test, and it would add an additional branching path to the generation. Instances are the way to go for this kind of stuff. (specially if you need to mock them in your code.
transferring class & method comments
This info is a bit harder to acquire, but I know we wanted to look at it ineventually.
transferring methods from classes
Technical feasibility is very limited. Unity is running C#8, whereas you can run up to C#13 on CloudCode. This doesnt even take into account the .NET version you are running, or the dependencies you might be running on the CloudCode side. However, if you are intent on doing this, you can do this easily manually by keeping your DTOs in Unity and sharing them with the C# side using a Compile item group on the CloudCode side:
Hey,
Do you mind specifying which bug? If it is enum generation, its on the backlog, planned for later.
If it’s the specific crash, that is fixed in 2.8, what version of the Cloud-code package / Deployment package are you using?
2.8 and 2.9 had a number of fixes and improvements to cloud-code, I recommend latest.
## [2.8.0] - 2024-10-18
### Added
- View in Deployment Window button in `.ccmr` and `.js` files, dependent on Deployment package version 1.4.0.
- View in Dashboard button in inspector for `.ccmr` and `.js` files.
- View in Dashboard context menu in Deployment Window for `.ccmr` and `.js` files.
- Add `Open Solution` button to `.ccmr` inspector.
- Add Enum support for Cloud Code Bindings generation.
### Fixed
- Fixed support for various primitive types in Cloud Code Modules binding generation
- In-script parameters analysis throws an exception in Unity 6
- `Browse...` button in `.ccmr` inspector now opens the current solution folder properly.
- Fixed Cloud Code Binding generation of primitive types
- Binding Generation will attempt to run in the latest available runtime.
- This can be disabled with CLOUD_CODE_AUTHORING_DISABLE_VERSION_DETECT flag
I got the same error as XamverGames at the top of this thread; whenever I tried to generate bindings for a module containing: “config.Dependencies.AddSingleton(AdminApiClient.Create());”
But as I kept poking around it turned out that Visual Studio automagically installed v9 of Microsoft.Extensions.Logging.Abstractions. I downgraded to v7 and now everything is working.
Im glad that worked out. To help with the feedback, what version of the com.unity.services.cloudcode package were you using, what .NET versions do you have installed (dotnet --list-runtimes, dotnet --list-sdks), and was the project compiling?
I wanna see if there’s something we can improve in the feedback.
The cloud code module was indeed compiling even though creating bindings failed. My first workaround was to comment out “config.Dependencies.AddSingleton(AdminApiClient.Create());”
and create the bindings, then reactivate the above code, before compiling/deploying. Which worked, with a bit of tweaks to the bindings script.
It would definitely have been great to get a note in the Console that the Microsoft.Extensions.Logging.Abstractions version wasn’t supported. The DotNet error code wasn’t exactly helpful
Hi, the AdminApiClient isn’t necessary for matchmaking in Cloud Code, the IMatchmakerTicketsApi on the GameApiClient is what you need. You would first call CreateTicketAsyc, then poll its status using GetTicketStatusAsync (alternatively you can call MatchmakerService.Instance.GetTicketAsync directly from the client).
You can check/update your version of the Core package through the Nuget package manager in your IDE. There are a few ways to access this, but probably the simplest is to right click on your project in the solution view and choose “Manage Nuget Packages” (I believe this is an option on both Visual Studio and Rider). You can then choose the package from the list, choose the version you want from the dropdown (it should default to the latest version) and hit the install/upgrade button.