Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Calling C# Module endpoint (Cloud Save feature)

Discussion in 'Cloud Code' started by hyunwookimbob, Apr 28, 2023.

  1. hyunwookimbob

    hyunwookimbob

    Joined:
    Mar 10, 2023
    Posts:
    8
    I was testing Cloud Code with C# Module and managed to call the 'SayHello' function provided in the document. But, I'm unsure how to call the function below from the client-side script.

    Code (CSharp):
    1. [CloudCodeFunction("SaveData")]
    2.     public async void SaveData(IExecutionContext context, IGameApiClient gameApiClient, string key, object value)
    3.     {
    4.         try
    5.         {
    6.             await gameApiClient.CloudSaveData.SetItemAsync(context, context.AccessToken, context.ProjectId, context.PlayerId, new SetItemBody(key, value));
    7.         }
    8.         catch (ApiException ex)
    9.         {
    10.             throw;
    11.         }
    12.     }
     
  2. hyunwookimbob

    hyunwookimbob

    Joined:
    Mar 10, 2023
    Posts:
    8
    oh... I forgot to deploy it with this line of code.

    config.Dependencies.AddSingleton(GameApiClient.Create());