Skip to main content
Version: 5.11.6

Full Code

BackendLogin.cs

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

// Adds BACKND SDK namespace
using BackEnd;

public class BackendLogin {
private static BackendLogin _instance = null;

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

return _instance;
}
}

public void CustomSignUp(string id, string pw) {
Debug.Log("Requesting sign-up.");

var bro = Backend.BMember.CustomSignUp(id, pw);

if(bro.IsSuccess()) {
Debug.Log("Sign-up successful. : " + bro);
} else {
Debug.LogError("Sign-up failed. : " + bro);
}
}

public void CustomLogin(string id, string pw) {
Debug.Log("Requesting login.");

var bro = Backend.BMember.CustomLogin(id, pw);

if(bro.IsSuccess()) {
Debug.Log("Login successful. : " + bro);
} else {
Debug.LogError("Login failed. : " + bro);
}
}

public void UpdateNickname(string nickname) {
Debug.Log("Requesting nickname change.");

var bro = Backend.BMember.UpdateNickname(nickname);

if(bro.IsSuccess()) {
Debug.Log("Nickname change successful : " + bro);
} else {
Debug.LogError("Nickname change failed : " + bro);
}
}
}

BackendManager.cs

using System.Collections;
using System.Collections.Generic;
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.CustomSignUp("user1","1234"); // [Addition] BACKND sign-up(handled as comment)

BackendLogin.Instance.CustomLogin("user1","1234"); // [Addition] BACKND sign-up

BackendLogin.Instance.UpdateNickname("Desired nickname"); // [Addition] Change nickname
Debug.Log("Test complete.");
});
}
}