Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Official New Cloud Code C# Module Release (2.6.1)!

Discussion in 'Cloud Code' started by chengg_unity, Apr 12, 2024.

  1. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    73
    Hello everyone!

    We are excited to release version 2.6.1 of Cloud Code C#! This release makes working with Cloud Code much easier and greatly improves your productivity. You can now automatically generate your game runtime code for your Cloud Code C# module!

    Refer to the Demo and Documentation(Generate Bindings) for more information!
     
    CodeSmile and BackgroundMover like this.
  2. MaximeDelecourt

    MaximeDelecourt

    Unity Technologies

    Joined:
    Oct 21, 2021
    Posts:
    21
    Here is an example of how you can now automatically generate a type-safe wrapper for your Module, significantly reducing the amount of boilerplate code needed to make calls to Cloud Code from your game client.

    Given the following method exposed in Cloud Code:
    Code (CSharp):
    1. [CloudCodeFunction("SayHello")]
    2. public string SayHello(string name)
    3. {
    4.     return $"Hello, {name}!"
    5. }

    Previously, in order to call this endpoint from your game client, you would need to write the following:
    Code (CSharp):
    1. var message = CloudCodeService.Instance.CallModuleEndpointAsync<string>(
    2.     "MyModule",
    3.     "SayHello",
    4.     new Dictionary<string, string>( ) { { "name", "Bob" } });

    With the new Bindings feature, this code can be greatly simplified to something like this:
    Code (CSharp):
    1. var message = myModule.SayHello("Bob");
    Custom classes used in your arguments or return types are included in the generated package, removing the need to manually duplicate these classes between your cloud and client code.
     
    pKallv and GabKBelmonte like this.
  3. AndreaGalet

    AndreaGalet

    Joined:
    May 21, 2020
    Posts:
    103
    Are Bindings automatically generated when changing the cloud code script? or do i must re generate them manuallly?
     
  4. GabKBelmonte

    GabKBelmonte

    Unity Technologies

    Joined:
    Dec 14, 2021
    Posts:
    154
    Negative, you must generate them manually. It's a tradeoff, since as you iterate on your module (and tests for your module as applicable), we'd be breaking your project if we re-gen your bindings. But we'll take the feedback into account.

    To be clear, it only supports Cloud Code C# modules , not Cloud Code JS scripts at the moment
     
    AndreaGalet likes this.
  5. AndreaGalet

    AndreaGalet

    Joined:
    May 21, 2020
    Posts:
    103
    Copy