How to use

Complete Account with Database Asset

  • Version 1.0.1

Get Started



You must imperatively have the playfab SDK in your project. This is a service that will be used to store all player data. Normally this one is attached in the asset, but if you encounter errors delete it and download it here.


Create Your PlayFab Account

Once you have the sdk, you must create a PlayFab account. Go here.


  • Congratulations, you are now connected to the Play Fab services, all you have to do is create your application, to do so, simply follow the steps indicated. You should have this:

    Responsive image

  • Now click on your game to access this information, then follow this video.
    This step is very important, it will allow users to store their data.

    WARNING by checking this box, your game can be submitted to cheat!
    So follow this step only if you want unsecured data transfer.

  • Now, all you have to do is retrieve your game ID, in the settings, from where you were:
    Responsive image
    Copy your Title ID to your clipboard and proceed to the next step.

  • So, now you can go back to Unity to set up your project. In the action bar, go to Database Controller > Settings
    Responsive image
    This window should then open:
    Responsive image

  • Go to the scene you will use for your connection system.

    ATTENTION only one scene can be used per project to avoid any problems.

    Then, in the settings window that was opened earlier, click the “Create this object for me” button. After which, you can enter your application ID (step 3) in the Project ID selection.

    If you are developing a mobile game, and would like to use the anonymous connection option, please switch your project to iOS or Android if you haven’t already done so. This option is only available for mobile.

    Now all you have to do is fill in all the necessary objects in the management window and press “Apply”.
    A confirmation message should appear in the Unity console.

Congratulations, you have successfully configured your project.
Now you can build your level in order to implement the login system for the user.
You can help yourself from the demo scene to better understand.

Implementations (Unity C#)

1 - Get Started

In order to properly prepare your system, you will need only one thing, a script that will manage the elements of your scene.

If you have a problem or hesitation, do not hesitate to consult our demo script, or join us on discord.

Step 1: Open your script, and at the top, insert the following line : ‘using DatabaseAPI.Account;’
Responsive image
(this is our demo script, you can find it in the asset folder > Demo > scripts).
Now, you're able to use our asset in your script.

ATTENTION more namespace can be used, refer to the Extras part of this documentation.

2 - Connection

Step 1: Once the API is imported into your script, you can create your first calling functions.

Here are the available instructions:

  • public void GetUserName(string value) { AccountController.controller.GET_USER_USERNAME(value); }

  • public void GetUserEmail(string value) { AccountController.controller.GET_USER_EMAIL(value); }

  • public void GetUserPassword(string value) { AccountController.controller.GET_USER_PASSWORD(value); }

  • AccountController.controller.LOGIN_ACTION();

  • AccountController.controller.ON_CLIC_CREATE_ACCOUNT();

  • AccountController.controller.LOG_OUT();

Step 2: All right, now, save and go back to unity to link these new functions to your buttons.

The first 3 functions listed above must be added to InputFields, in the “On Value Changed” section.

Responsive image
CAUTION choose the Dynamic string, otherwise your function will not work.

Responsive image
ATTENTION be careful, it's not necessary, but you can select the true option in Content type, Email Address for email, Password for the password, and standard for username.

Now, you just have to put the login or connect function to your button in the on Click function.

3 - Mobile Anonymous Connection

This anonymous login allows the user to start playing without creating an account. The anonymous login still create an account to the user, which will allow him an automatic login every time the application opens. Its ID and password will be defined by its phone ID. Using the anonymous connection does not prevent linking your profile to an existing account or a new one afterwards.

The following step can be found in the demo script, from line 233 to 244.

Step 1: Write the new functions in your script

  • public void OpenCloseRecoverySection() { AccountController.controller.OPEN_RECOVERY_PANEL(); }

  • public void CreateRecoveryAccount() { AccountController.controller.ON_CLIC_ADD_RECOVERY(); }

4 - User Statistics (unsecure)

This section is relatively simplistic, everything is already done for you.

The first thing to know, is that when connecting, all user data is stored in a local dictionary.
You can view it and retrieve this data by simply typing:
AccountController.playerData.TryGetValue(NAME OF THE VALUE SAVED, out VALUE TO UPDATE)
You can see this template in the demo script, line 64.

How to save new data or update one:
AccountController.controller.SetStat(NAME OF THE VALUE TO SAVED, VALUE TO SAVE);
You can see this template in the demo script, line 104.

5 - User Statistics (securized)

The first thing to know, is that when connecting, all user data is stored in a local dictionary (the same as the previous section).

  • First, if you are using the backup method from the previous section, go back to the PlayFab settings, and uncheck the “Allow client To post player statistics” box in API Features.
    (made the opposite of the step 2 in the configuration section)

    Next, configure your cloud script.

    On your project dashboard, go to “Automation” and then choose “Revisions” in the “Cloud Script” section:
    Responsive image
    Once this is done, you can start writing.

    If you have never touched your revisions, you can delete all its content, and write:

    handlers.UpdatePlayerStats = function (args, context) {
     var request = {
      PlayFabId: currentPlayerId, Statistics: [{
     var playerStatResult = server.UpdatePlayerStatistics(request);
     return{messageValue: "Updated Statistics"}
    Responsive image
    This is the function used for the demo script.

  • AccountController.playerData.TryGetValue(NAME OF THE VALUE SAVED, out VALUE TO UPDATE)
    You can see this template in the demo script, line 64.

    How to save new data or update one:

    public int userLevel; // user data variable

    public void UpdateLevel(int value)
     userLevel += value // update the variable
     StartUpdatePlayerStatsSecure(); // call the cloud script update function

    private void StartUpdatePlayerStatsSecure()
     if (AccountController.controller.secureDataSave)
      PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
       FunctionName = "UpdatePlayerStats", // cloud function name
       FunctionParameter = new { CLOUD SCRIPT ARGS NAME = userLevel },
       GeneratePlayStreamEvent = true, // Optional - Shows this event in PlayStream
      }, AccountController.OnCloudUpdate, AccountController.OnErrorShared);
    You can see this template in the demo script, line 205.

6 - Friends

Letting players connect with their friends is a great engagement tool for your game! PlayFab offers you the ability to manage your own custom friends lists within your game.

Any player in your title may be friends with any other player in your title. Notably, friendship on PlayFab is a one-way street.

If Julie adds Bob as a friend, there is no approval process for Bob. In fact, Bob may be unaware.

Bob must separately add Julie for the friendship to be mutual.

If you wish to have reciprocity rules, it is your title's responsibility to enforce these conditions with a custom game server or CloudScript logic, if necessary, but this is not yet integrated into this asset.

To start, you need to make your friend panel, you can recover the one from the demo scene. Then, in the asset settings window, go to the “Friends” section and fill all the fields.
For the “Friend listing prefab”, you can use the demo one.
Responsive image

Then click “Apply” to save the selection.

Once that is done, it is time to code. Rest assured, you will only have one or two minutes.
First, you need to choose a method of adding friends.

Four methods are pre-built: Add by Play Fab ID, add by email, add by account username, and add by user name displayed in game.
The calls are respectively:

These functions require a parameter, a string that will contain either the user’s ID, or his email, etc.

For example:
using DatabaseAPI.Multiplayer;

public string friendsID;

public void UpdateFriendSearchID(string FriendID)
 friendsID = FriendID;

public void AddFriend()

public void OpenCloseFriends()
UpdateFriendSearchID is a feature to integrate into the “OnValueChange” of an Input Field, as done previously to connect a user.
Find this model line 218 to 231 of the demo script.

7 - Leaderboard

Leaderboards are essentially rankings of entities such as players. A leaderboard ranks a list of entities based on their respective values. For example, “High Scores” is one of the most common implementations of leaderboards.

Two types of leaderboards are available in this asset, a global leaderboard, for example to show the player, the best worldwide based on a precise statistic, the best score in the demo scene.
And a friend leaderboard, which shows the ranking of friends according to a statistic, here again, this is the best score that is used in the demo scene.

  • Before you start, make sure you have prepared your scene and fill in the corresponding section in the asset settings window:
    Responsive image
    For the leaderboard listing prefab, you can use the one integrated in the asset, in the Prefabs folder.

    Once this is done, you can start coding, everything is already ready, you only have two functions to call:

    using DatabaseAPI.Multiplayer;

    public void OpenLeaderboard()
     LeaderboardController.OpenLeaderboard(STAT NAME, MAX USER TO DISPLAY);

    public void CloseLeaderboard()
    Find this model line 185 to 193 of the demo script.

  • Again, configure the settings in the editor window
    Responsive image
    For the leaderboard listing prefab, you can use the one integrated in the asset, in the Prefabs folder.

    Once this is done, you can start coding, everything is already ready, you only have two functions to call:

    using DatabaseAPI.Multiplayer;

    public void OpenFriendsLeaderboard()
     LeaderboardController.OpenFriendsLeaderboard(STAT NAME, MAX USER TO DISPLAY);

    public void CloseFriendsLeaderboard()
    Find this model line 195 to 203 of the demo script.

8 - Virtual Currency

Currencies can be used to purchase Items from the Catalog or a Store, can represent soft currency converted from In App Purchases, or can be used as a mechanic to drive gameplay.
Most games support at least two virtual currencies. Many use a “soft” currency that can be earned in-game through play, and a “hard” currency that can be bought. Having dual currencies gives you more control over your economy, since you can determine which items can be bought.
See official PlayFab tutorial on Currencies.

Step 1: Create your virtual currency in PlayFab Dashboard

Responsive image
Then, follow the instructions.

Step 2: Update your Cloud Script

On your project dashboard, go to “Automation” and then choose “Revisions” in the “Cloud Script” section:
Responsive image

Once this is done, you can start writing:
handlers.AddCurency = function (args, context) {
 server.AddUserVirtualCurrency({PlayFabId: currentPlayerId, VirtualCurrency:, Amount: args.amount});
 return{messageValue: "+" + + " currency"};

handlers.SubCurency = function (args, context) {
 server.SubtractUserVirtualCurrency({PlayFabId: currentPlayerId, VirtualCurrency:, Amount: args.amount});
 return{messageValue: "-" + + " currency"};

Step 3: Implementation in Unity

To get started, you need to enable the use of virtual currencies in the editor window.
Go to: Database Controller > Settings > Virtual Currency > Enable virtual currency > Apply

  • You should know that your virtual currencies are then stored in a 'virtualcurrency' dictionary, so you can access it at any time, this dictionary is updated each time you log in, or you change one of these values, which will also change it in PlayFab.

    So, to get your currency, you just need to type:
    AccountController.controller.virtualCurrency.TryGetValue(CURRENCY CODE, out VARIABLE TO PUT THE VALUE);
    Find this model line 83 of the demo script.

  • Only one method, everything is ready for you:
    AccountController.UpdateCurrency(CURRENCY CODE, AMOUNT, ADD OR SUBTRACT);
    Find this model line 122 of the demo script.

9 - User Data (under development)

To access your user’s data, go to the playfab dashboard, go to the Player section, then select the desired user, and finally select Player Data (Title).

The following code corresponds to the one you can find in the demo script, from lines 247 to 293.

The SetUpStore function lets you know which skins have already been purchased by the player.
Then, the UnlockSkins function and the one that will be associated with a button to unlock the skin associated with this button.
And finally, the SetThisSkin function allows you to equip one of the skins.

public void SetUpStore()
 for (int i = 0; i < PersistantData.pd.allPlayserSkins.Length; i++)
  unlockedButtons[i].interactable = PersistantData.pd.allPlayserSkins[i];

public void UnlockSkin(int index)
 int price = 0;
 if (index == 1)
  price = 100;
 else if (index == 2)
  price = 200;
 else if (index == 3)
  price = 300;
 else if (index == 4)
  price = 400;
 else if (index == 5)
  price = 500;
 else if (index == 6)
  price = 600;

 if (money >= price)
  PersistantData.pd.allPlayserSkins[index] = true;
  AccountController.controller.SendDebugMessage("Not enought money");
  Debug.Log("Not enought money");

public void SetThisSkin(int index)
 PersistantData.pd.currentSkin = index;
If you need to know what is the currently used skin, call the variable (int) PersistantData.pd.currentSkin


In this last part of the Asset manual, you can find several small functions that may be useful to you.
  • You can say that this option has no interest, but on the contrary, it’s necessary! When you log in, how do you know if that connection failed, and therefore how do you make sure that you can start the next scene, such as a main menu.

    To access this information, you have this boolean available:
    If you are logged in, this boolean will return True.
    If you are looking for how to integrate it, you can consult the demo script of line 53 to 60.

  • Looking at these lines 53 to 60 of the demo script, you must have seen this:
    This statement is also a boolean. It allows to know the state of loading of the user’s data. This boolean will equal True when all data is finished loading.
    This option allows for example the use of a loading screen, to avoid that once logged in, the user sees erroneous data because not yet updated.

  • It’s also one of the most important elements, how to warn the user of a failure.

    To do this, you have access to a variable that will allow you to directly retrieve the entire error message:
    this simple command allows you to retrieve the error message, then you can either process it or return it as it was to the user.

    Example of use:
    public Text errorMsg; // using UnityEngine.UI;
    void Update() { errorMsg.text = AccountController.DebugMessage; }

    If you want to send your own debug message, just type:
    AccountController.controller.SendDebugMessage(YOUR MESSAGE);

  • Do you need your player’s server ID? you can retrieve it by typing AccountController.userID

    User Id is a string that will contain the id of the currently connected player.

    You can find it in the demo script, from lines 69 to 76.

  • Do you need your player’s Name? you can retrieve it by typing AccountController.userName

    User name is a string that will contain the id of the currently connected player.

  • If you have errors about not having access to some scripts, check that you are using the correct namespace

    Here are the different namespace you may need:
    using DatabaseAPI.Multiplayer;
    using DatabaseAPI.Account;
    using DatabaseAPI.Data;
    using PlayFab;

Want more astuces? join us on discord.

How to use PlayFab dashboard

  • Responsive image

  • Once on the players reference page, click on one of the list to access their profile.

    Once on a profile, the Overview page references this personal data, then the Statistics section will show you its data that you have chosen to save online, and finally, the Logins section will show you these latest connections.

    The other sections will probably not be useful to you with this asset, as they are not compatible.

    To go to your dashboard, in the unity action bar go to: Database Controller > Your Dashboard

Want more astuces? join us on discord.