Search Unity

Question How Is Data Linked To Players

Discussion in 'Cloud Save' started by TomTheMan59, Oct 27, 2021.

  1. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
    I was wondering how this works without an account?

    “Since it's cloud-based, the player data is accessible anywhere and across devices, mitigating data loss when a player changes devices or re-installs a game.”

    If a player changes phones or just deletes and reinstalls, how will it know that is the same player? Does this use iCloud or Google Drive?
     
  2. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    220
    Hi Tom,

    Thanks for posting your question.

    You must iniialize Cloud Save and its dependencies, including Authentication in order to log the playerID and start using Cloud Save.

    The Authentication package provides methods to sign in the player anonymously, or using a platform sign-in. It is this capability that identifies the player and can be used ensure that player progress is synchonisd across multiple devices.

    The following documents should help:
    Cloud Save Example
    Authentication Best Practices

    Cloud Save isn't saving to iCloud or Google Drive, but the player can use a Google or Apple authenticated sign in mechanism to link devices.

    I hope this answers your question, please let us know how you get on or if you have any further questions.
     
    SebT_Unity likes this.
  3. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
    That helps thanks! I wanted to avoid having the player make an account. I guess I will wait for Unity to hopefully make a plugin for saving to iCloud or Google Drive. Is there any plans?
     
  4. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    220
    Hi Tom,

    The Authentication package supports anonymous sign-in and platform specific sign-in. If you use anonymous sign-in the player doesn't need to create an account, the process is invisible to them. Anything you save to Cloud Save whilst anonymously logged in can be fetched in subsequent game sessions. This is ideal for storing player progress etc..

    This Example in the Cloud Code documentation uses anonymous sign-in to save and load player data.

    I'm not aware of any plans to develop iCloud or Google Drive storage, and I'm not sure I understand what your use case for that would be. But, please let me know more about your intended use case if the example above doesn't do what you need. We really want to hear what developers want to build with Gaming Services so we can provide you with the best tools.
     
  5. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
    Thank for the reply.

    From my understanding, if they change devices this will not work using anonymous. I would have to do like you mentioned and have them sign in via a platform specific sign-in.

    With Apple or Google Drive storage, this would allow the player to already be signed into their own account and the data would be saved across their various devices on platform specific devices. So for example on iOS, it would work with iPad, iPhone, macOS.

    I don't have any desire (and I don't know if other developers feel the same way) to implement a platform specific sign-in for smaller games. Take Geometry Dash for instance. It would feel weird to have to sign-in to a game like that or any infinite runner type games. I honestly don't know any app I have downloaded where I need to sign in. All my iOS games save via iCloud and it works perfectly.

    Hope everything I said is clear! Let me know if I am unclear anywhere :)
     
  6. StevenStip-Unity

    StevenStip-Unity

    Unity Technologies

    Joined:
    Apr 7, 2021
    Posts:
    22
    Hi Tom, The platform sign-in with Apple and Google is much like you described something that happens behind the scenes.

    For example if you have an Android phone you're likely already signed into your Google account in order to download the game from the Play store. If you enable the Google platform sign-in as described here. The login will happen in the background for the player. Only when you have multiple Google accounts on your phone you will be asked to pick which one to use.

    The reason we use anonymous login as the default is that it is something that doesn't have any pre-requisites and can get you up and running really quickly. We do expect almost everyone releasing a mobile game to implement the platform logins they are releasing the game for.

    I hope this clears up what the player experience is for the platform login.
     
  7. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
    If I understand this correctly, I was wrong about how it worked! I was thinking about the Sign-In With Apple or Google button where it would make a separate account from their iCloud/Play account.

    So this is the workflow?
    1. The user opens the game on their iPhone.
    2. You call
      Code (CSharp):
      1. SignInWithSessionToken
      and it will make the saved data (or grab it) using their iCloud account's authentication in the background. (No Sign-In With Apple or making a separate account from their iCloud one).
    3. The user goes to their iPad that is also signed into their same iCloud account. You can just call that same method and it will get the correct data.
    4. The user opens the game on macOS, but they aren't signed into iCloud. It will make an anonymous account which you can then, if choose, have a button where it prompts them to sign in to their iCloud account or make a new one.
    Thanks for all the information!
     
  8. unity_Ctri

    unity_Ctri

    Unity Technologies

    Joined:
    Oct 20, 2020
    Posts:
    81
    Hey Tom,

    To clarify on a couple of points
    2. As I understand it the session token is intended as a speedy way of logging an existing user back in - to continue their session.
    This requires and assumes that the user has already logged in already - one way or another.

    3. You can log in using an iCloud ID and if an account on our side doesn't already exist - it will be created. If one already exists, it will be logged into.
    4. Creating an anonymous account isn't automatic, you have to expressly decide to do that in your game's code. Doing so allows the user to start progressing their game using the back end services without forcing a sign-in. The risk with anonymous accounts is that if you lose the session token, you no longer have a way of logging the user back in.

    We allow you to link an existing account (e.g. one created with an anonymous sign-in) with a sign-on provider so that users can recover their progress or access it on a different device.

    Hope that helps clear things up!
     
    Last edited: Dec 15, 2021
  9. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
    Thanks for the information!
     
    unity_Ctri likes this.
  10. Seforius

    Seforius

    Joined:
    Jun 25, 2022
    Posts:
    10
    @unity_Ctri Does Cloud Save automatically associate all saved data with the currently signed in player? For example, if I try to load data with a specific key, will the CloudSave API calls only look for the data with the key I specified that is specified with the signed in player?
     
    StevenStip-Unity likes this.
  11. Unity_AndyP

    Unity_AndyP

    Unity Technologies

    Joined:
    Jun 23, 2021
    Posts:
    63
    That is exactly right. With the authentication package, the only data you can pull down is that of the user currently using the device. This is due to the token that gets generated on the client, without this you won't be able to access the data.

    To carry this token across to other devices you will need to use the authentication service with an identity provider instead of using anonymous sign-in, you can find documentation on how to do this here.

    We don't allow users to access another user's data through the client but you can use something like cloud code so it's all done server-side for something like this. An example of how to do this can be found here.