Skip to main content
Version: 5.11.6

Multi Project Registration

Initialization of configuration values upon importing SDK

When a new version of SDK is imported and new functions are added to the Multi Project function, the configured Multi Project function may be initialized.

After importing an SDK, make sure to check if The Backend Multi Setting's information has not changed.

Example of Using Multi Project

Multi Project can be used in the following cases:

  • When dividing a game's (build's) server into the test server and the live server
  • When dividing a game's (build's) different servers that are not synchronized by country.

How to Use

1. Configure the BACKND Inspector

Click The Backend > Edit Multi Settings on the upper section of Unity.

Add the projects.

2. Write the codes

Projects configured in the inspector can be loaded using BackEnd.MultiSettings.MultiSettingManager.
You can load a project by searching its project name using MultiSettingManager.FindByProjectName.
If the project does not exist, null is returned.

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

public class BackendManager : MonoBehaviour {
void Start() {
BackEnd.MultiSettings.MultiProject multiProject = BackEnd.MultiSettings.MultiSettingManager.FindByProjectName("USA");

if(multiProject == null) {
Debug.LogError("The project cannot be found.");
}

var bro = Backend.InitializeByMuiltiProject(multiProject,true, true);

if(bro.IsSuccess()) {
Debug.Log("Initialization was successful.");
} else {
Debug.Log("An error has occurred during initialization" + bro);
}
}
}

Select project for initialization

You can also make users select a project.
The following is a method that loads the list of saved projects, makes a button, and initializes to the project when the button is clicked.

    [SerializeField] private GameObject multiCharacterButtonObject;

public void Initialize() {
List<MultiProject> multiProjectList = MultiSettingManager.theBackendMultiSettings.projectList;

for(int i = 0; i < multiProjectList.Count; i++) {
var obj = Instantiate(multiCharacterButtonObject, multiCharacterListGroup, true);
obj.transform.localScale = new Vector3(1, 1, 1);
int index = i;
obj.GetComponentInChildren<TMP_Text>().text = multiProjectList[i].projectName;
obj.GetComponent<Button>().onClick.AddListener(() => {
string clientAppId = MultiSettingManager.theBackendMultiSettings.projectList[index].clientAppId;
string signatureKey = MultiSettingManager.theBackendMultiSettings.projectList[index].signatureKey;

InitializeBackend(clientAppId, signatureKey);
});
}
}

private void InitializeBackend(string clientAppId, string signatureKey) {

BackendCustomSetting backendCustomSetting = new BackendCustomSetting();

backendCustomSetting.clientAppID = clientAppIdInputField.text;
backendCustomSetting.signatureKey = signatureKeyInputField.text;
backendCustomSetting.useAsyncPoll = true;

var bro = Backend.Initialize(backendCustomSetting);

if(bro.IsSuccess()) {
Debug.Log("Initialization was successful!");
} else {
Debug.LogError("An error occurred while initializing!\n“ + bro.ToString());
}
}