Skip to main content
Version: 5.11.6

Registering Rankings

1. Copy the ranking UUID from BACKND Console

Go to BACKND Console and copy the UUID of the ranking created in BACKND Base > Ranking Management.

2. Write a game information insertion method

Add content to the RankInsert method in BackendRank.cs written in Pre-arrangements.

At this time, paste the UUID of the ranking copied in No. 1 as the string rankUUID value of the RankInsert method.
Example: "Copied UUID value" -> "4088f640-693e-11ed-ad29-ad8f0c3d4c70"

BackendRank.cs

Before editing

    public void RankInsert(int score) {
// Adds content of Step 2. Inserting Rankings
}

After editing

    public void RankInsert(int score) {
// [Change required] Change the 'copied UUID value' to the UUID value of the ranking created in 'BACKND Console > Ranking Management.'
string rankUUID = "Copied UUID value"; // Example: "4088f640-693e-11ed-ad29-ad8f0c3d4c70"

string tableName = "USER_DATA";
string rowInDate = string.Empty;

// The inDate value of the data used in the game data is required to insert a ranking.
// Therefore, you must load the data and extract its inDate value.
Debug.Log("Attempts data lookup.");
var bro = Backend.GameData.GetMyData(tableName, new Where());

if(bro.IsSuccess() == false) {
Debug.LogError("An error has occurred while looking up data : " + bro);
return;
}

Debug.Log("Data lookup successful : " + bro);

if(bro.FlattenRows().Count > 0) {
rowInDate = bro.FlattenRows()[0]["inDate"].ToString();
} else {
Debug.Log("The data does not exist. Attempting data insertion.");
var bro2 = Backend.GameData.Insert(tableName);

if(bro2.IsSuccess() == false) {
Debug.LogError("An error occurred while inserting data : " + bro2);
return;
}

Debug.Log("Data insertion successful : " + bro2);

rowInDate = bro2.GetInDate();
}

Debug.Log("rowInDate of my game information : " + rowInDate); // The extracted rowIndate value is as follows:

Param param = new Param();
param.Add("level", score);

// Edits the data with the extracted rowIndate to the param value and updates the data for the ranking.
Debug.Log("Attempting ranking insertion.");
var rankBro = Backend.URank.User.UpdateUserScore(rankUUID, tableName, rowInDate, param);

if(rankBro.IsSuccess() == false) {
Debug.LogError("An error has occurred while registering the ranking. : " + rankBro);
return;
}

Debug.Log("Successfully inserted the ranking. : " + rankBro);
}

3. Add method call to BackendManager.cs

BackendManager, which is automatically called when the game is executed, must be used to call this method.
Add it so that the method may be called after BACKND initialization and BACKND login.

BackendManager.cs

Before editing

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234"); // BACKND login

// Adds a logic to implement ranking functions

Debug.Log("Test complete.");
});
}

After editing

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234"); // BACKND login method

BackendRank.Instance.RankInsert(100); // [Addition] Ranking registration method

Debug.Log("Test complete.");
});
}

4. Test in Unity

After editing the script, execute Unity debugging and check the console log of Unity.

The method has been successfully called when the log displays 'Successfully inserted the ranking. : statusCode : 204'.
When errors, such as statusCode : 400, 404, 409, occur instead of the above log, you can check which error caused the failure in UpdateUserScore error case.

Error case

An error occurred while looking up rankings. : statusCode : 404
errorCode : NotFoundException

Change the copied UUID value in the first line of the method, string rankUUID = "Copied UUID value"; to the actual UUID of the ranking created in the console.

5. Check in the console

Go to BACKND Console and click the ranking created in BACKND Base > Ranking Management to check the user's place in the ranking.