Pre-arrangements
The following tasks must be completed in advance to implement login/sign-up functions.
- Insert BACKND initialization logic
- 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 BackendManager.cs does not affect the test.
BackendManager.cs script
Add a test method that will call synchronous methods from asynchronous methods following the initialization logic in Getting Started.
Before modification
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Add BACKND SDK namespace
using BackEnd;
public class BackendManager : MonoBehaviour
{
void Start()
{
var bro = Backend.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 modification
using UnityEngine;
// Add BACKND SDK namespace
using BackEnd;
public class BackendManager : MonoBehaviour
{
void Start()
{
var bro = Backend.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();
}
void Test()
{
}
}
2. Create a script exclusive to login
Create a new script and change the name to BackendLogin.
BackendLogin.cs
Then, open the BackendLogin.cs script and change the content according to the following:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Add 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)
{
// Logic for Step 2. Implementing Sign-up
}
public void CustomLogin(string id, string pw)
{
// Logic for Step 3. Implementing Login
}
public void UpdateNickname(string nickname)
{
// Logic for Step 4. Implementing Nickname Change
}
}