Hello, im making online games with socket.io. I have problem on function call backs. Can someone help me for fix this problem ?
Login callback working correctly.
void LoginCallBack(SocketIOEvent e) {
JSONObject data = e.data;
if (data.GetField("msg").ToString().Contains("Logined")) {
mScript.Logined();
}
}
Here is the mScript.Logined() function:
public void Logined() {
OpenScreen(3);
}
This functions working correctly. But ErrorCallBack returning error “SetActive can only be called from Main Thread”
void ErrorCallBack(SocketIOEvent e) {
mScript.SocketError();
}
Here is the mScript.SocketError() function:
public void SocketError() {
OpenScreen(2);
}
OpenScreen function:
void OpenScreen(int id) {
for (int i = 0; i < uiScreens.Length; i++) {
if (i == id) {
uiScreens[i].gameObject.SetActive(true);
} else {
uiScreens[i].gameObject.SetActive(false);
}
}
}