Skip to main content
Version: SDK-5.11.2

Loading 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 RankGet method in BackendRank.cs written in Pre-arrangements.

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

BackendRank.cs

Before editing

    public void RankGet() {
// Adds content of Step 3. Loading Rankings
}

After editing

    public void RankGet() {
string rankUUID = "<copied UUID value>"; // Example: "4088f640-693e-11ed-ad29-ad8f0c3d4c70"
var bro = Backend.URank.User.GetRankList(rankUUID);

if(bro.IsSuccess() == false) {
Debug.LogError("An error occurred while looking up rankings. : " + bro);
return;
}
Debug.Log("Ranking lookup successful. : " + bro);

Debug.Log("Total number of users registered to the ranking : " + bro.GetFlattenJSON()["totalCount"].ToString());

foreach(LitJson.JsonData jsonData in bro.FlattenRows()) {
StringBuilder info = new StringBuilder();

info.AppendLine("Ranking : " + jsonData["rank"].ToString());
info.AppendLine("Nickname : " + jsonData["nickname"].ToString());
info.AppendLine("Score : " + jsonData["score"].ToString());
info.AppendLine("gamerInDate : " + jsonData["gamerInDate"].ToString());
info.AppendLine("Sort code : " + jsonData["index"].ToString());
info.AppendLine();
Debug.Log(info);
}
}

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(After Step 2. Ranking Registration)

    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.");
});
}

After editing

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

BackendRank.Instance.RankGet(); // [Addition] Ranking loading 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 'User information updated on the ranking'.
When errors, such as statusCode : 400, 404, and 409, occur instead of the above log being displayed, you can check which errors caused the failure in GetRankList error case.

Error case

An error occurred while looking up rankings. : statusCode : 404
errorCode : NotFoundException
message : rank not found, rank cannot be found

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.