Skip to main content
Version: 6.0.0

Pre-arrangements

The following tasks must be completed in advance to implement game information management functions.

  1. Logic of completed login method
  2. Create a game information table in BACKND Console
  3. Create a script exclusive to game information

1. Logic of completed login method

All BACKND functions except login and sign-up require a login process to successfully call their methods.
If the login logic has not been implemented, please implement it according to the guidelines in 1. Implementing Login/Sign-up.

2. Create a game information table in BACKND Console

Go to BACKND Console and click the 'Create Table' button in BACKND Base > Game Information Management > Table.

Create a table with the classification set to private and schema definition to disable.
In this example, the table name is set to USER_DATA.

If the table name is set to something other than USER_DATA, change the value called "USER_DATA" in each example to the name you set.

Click the created table and go to Game Information Management > Data.

The data in this table will be created after the test.

3. Create a script exclusive to game information

Create a new script and change the name to BackndGameData.
Then, open the BackndGameData.cs script and change the content according to the following:

using System.Collections.Generic;
using System.Text;
using UnityEngine;

// Adds BACKND SDK namespace
using BACKND;

public class UserData {
public int level = 1;
public float atk = 3.5f;
public string info = string.Empty;
public Dictionary<string, int> inventory = new Dictionary<string, int>();
public List<string> equipment = new List<string>();

// This is a method for data debugging.(Debug.Log(UserData);)
public override string ToString() {
StringBuilder result = new StringBuilder();
result.AppendLine($"level : {level}");
result.AppendLine($"atk : {atk}");
result.AppendLine($"info : {info}");

result.AppendLine($"inventory");
foreach(var itemKey in inventory.Keys) {
result.AppendLine($"| {itemKey} : {inventory[itemKey]}ea");
}

result.AppendLine($"equipment");
foreach(var equip in equipment) {
result.AppendLine($"| {equip}");
}

return result.ToString();
}
}

public class BackndGameData {
private static BackndGameData _instance = null;

public static BackndGameData Instance {
get {
if(_instance == null) {
_instance = new BackndGameData();
}

return _instance;
}
}

public static UserData userData;

private string gameDataRowInDate = string.Empty;

public void PlayerTableInsert() {
// Step 2. Implementing Game Information Insertion
}

public void PlayerTableGet() {
// Step 3. Implementing Game Information Loading
}

public void LevelUp() {
// Step 4. Implementing Game Information Editing
}

public void PlayerTableUpdate() {
// Step 4. Implementing Game Information Editing
}
}

BackndManager.cs

using UnityEngine;
using System.Threading.Tasks;

// Adds BACKND SDK namespace
using BACKND;

public class BackndManager : MonoBehaviour {
void Start() {
var bro = Backnd.Initialize(); // Initialize BACKND

// Response value for BACKND initialization
if(bro.IsSuccess()) {
Debug.Log("Initialization successful : " + bro); // If successful, 'statusCode 204 Success'
} else {
Debug.LogError("Initialization failed : " + bro); // If failed, a 4xx statusCode error occurs
}

Test();
}

// A method that allows synchronous methods to be called from asynchronous methods(cannot be accessed by the Unity UI)
async void Test() {
await Task.Run(() => {
BackndLogin.Instance.CustomSignIn("user1", "1234"); // BACKND login

// Adds a logic to implement the game information function

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