Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Other UGS integration with Cloud Code C#

Discussion in 'Cloud Code' started by mChapuis, Mar 26, 2024.

  1. mChapuis

    mChapuis

    Joined:
    Jun 23, 2014
    Posts:
    23
    Hello!
    I am looking to implement cloud save functionalities along with currency management (increment/decrement) using cloud code, specifically in C#. However, most available examples and documentation primarily focus on JavaScript and I would prefer the implementation to be in C#.

    I was able to run a module on UGS that doesn't require other gaming services or user auth, but I would need a basic code sample to know how to:
    1- save/load a value from Cloud Save from Cloud Code C# for a user
    2- update a currency for a user

    This is where I got..

    Code (CSharp):
    1.         [CloudCodeFunction("SubstractFromSubscriptionCount")]
    2.         public async Task<int> SubstractFromSubscriptionCount()
    3.         {
    4.             // dictionary saved previously for an int:
    5.             /*
    6.             Dictionary<string, object> startValueSubscription = new Dictionary<string, object>
    7.             {
    8.                 {currentSubscriptionReadingCount, TOTAL_SUBSCRIPTION_READINGS}
    9.             };
    10.             */
    11.             var fetchData = await CloudSaveDataApi... ?
    12.         }
     
  2. MariusUrbelis

    MariusUrbelis

    Unity Technologies

    Joined:
    Mar 15, 2015
    Posts:
    49
  3. mChapuis

    mChapuis

    Joined:
    Jun 23, 2014
    Posts:
    23
    I don't know how I missed that, I saw that page at least twice. Oh well!
    Thank you!
     
  4. GabKBelmonte

    GabKBelmonte

    Unity Technologies

    Joined:
    Dec 14, 2021
    Posts:
    162
    mChapuis and samg-unity like this.