Skip to main content
Version: 6.0.0

Pre-arrangements

The following tasks must be completed in advance to implement login/sign-up functions.

  1. Insert BACKND initialization logic
  2. Create a script exclusive to login/sign-up in BACKND

1. Create BACKND initialization logic script

This example covers the logic after Step 9 of BACKND developer documentation - Getting Started.
Therefore, the initialization logic in Getting Started must be written to test this example properly.

The location of the file of BackndManager.cs does not affect the test.

BackndManager.cs script

Add a test method that will call synchronous methods from asynchronous methods following the initialization logic in Getting Started.

Before editing

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

// 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
}
}
}

After editing

using UnityEngine;
using System.Threading.Tasks; // [Change] This namespace is needed to use the async function.

// 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();
}

// =======================================================
// [Addition] 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(() => {
// Adds later test cases
Debug.Log("Test complete.");
});
}
}

2. Create a script exclusive to login

Create a new script and change the name to BackndLogin.

BackndLogin.cs

Then, open the BackndLogin.cs script and change the content according to the following:

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) {
// Logic for Step 2. Implementing Sign-up
}

public void CustomSignIn(string id, string pw) {
// Logic for Step 3. Implementing Login
}

public void ChangeDisplayName(string nickname) {
// Logic for Step 4. Implementing Nickname Change
}
}