Skip to main content
Version: 5.11.4

Full Code

BackendGameLog.cs

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

// Adds BACKND SDK namespace
using BackEnd;

public class BackendGameLog {
private static BackendGameLog _instance = null;

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

return _instance;
}
}

public void GameLogInsert() {
Param param = new Param();

param.Add("clearStage", 1);
param.Add("currentMoney", 100000);

Debug.Log("Attempting to insert game log.");

var bro = Backend.GameLog.InsertLog("ClearStage", param);

if(bro.IsSuccess() == false) {
Debug.LogError("An error occurred while inserting the game log. : " + bro);
return;
}

Debug.Log("Successfully inserted game log. : " + bro);
}
}

BackendManager.cs

using UnityEngine;
using System.Threading.Tasks;

// Adds BACKND SDK namespace
using BackEnd;

public class BackendManager : MonoBehaviour {
void Start() {
var bro = Backend.Initialize(true); // 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(() => {
BackendLogin.Instance.CustomLogin("user1", "1234");

BackendGameLog.Instance.GameLogInsert(); // [Addition] Function for saving game logs

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