Full Code
BackndLogin.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Adds BACKND SDK namespace
using BACKND;
public class BackndLogin {
private static BackndLogin _instance = null;
public static BackndLogin Instance {
get {
if(_instance == null) {
_instance = new BackndLogin();
}
return _instance;
}
}
public void CustomSignUp(string id, string pw) {
Debug.Log("Requesting sign-up.");
var bro = Backnd.Player.CustomSignUp(id, pw);
if(bro.IsSuccess()) {
Debug.Log("Sign-up successful. : " + bro);
} else {
Debug.LogError("Sign-up failed. : " + bro);
}
}
public void CustomSignIn(string id, string pw) {
Debug.Log("Requesting login.");
var bro = Backnd.Player.CustomSignIn(id, pw);
if(bro.IsSuccess()) {
Debug.Log("Login successful. : " + bro);
} else {
Debug.LogError("Login failed. : " + bro);
}
}
public void ChangeDisplayName(string nickname) {
Debug.Log("Requesting nickname change.");
var bro = Backnd.Player.ChangeDisplayName(nickname);
if(bro.IsSuccess()) {
Debug.Log("Nickname change successful : " + bro);
} else {
Debug.LogError("Nickname change failed : " + bro);
}
}
}
BackndManager.cs
using System.Collections;
using System.Collections.Generic;
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.CustomSignUp("user1","1234"); // [Addition] BACKND sign-up(handled as comment)
BackndLogin.Instance.CustomSignIn("user1","1234"); // [Addition] BACKND sign-up
BackndLogin.Instance.ChangeDisplayName("Desired nickname"); // [Addition] Change nickname
Debug.Log("Test complete.");
});
}
}