/// <summary> /// Called when the server returns Login Success opcode /// </summary> /// <param name="netMsg"></param> protected void OnLoginSuccess(NetworkMessage netMsg) { UnityMainThreadDispatcher.Instance().Enqueue(() => { LoginPanel.SetActive(false); if (GameObject.Find("LoadingBox") != null) { Destroy(GameObject.Find("LoadingBox")); } //Create a spinner var spin = Instantiate(Resources.Load <GameObject>("Prefabs/Modals/LoadingBox"), UI.transform) as GameObject; spin.name = "LoadingBox"; spin.transform.Find("Text").GetComponent <Text>().text = "Loading Profile.."; //Read profileData var profileData = netMsg.ReadMessage <ProfileData>(); //We make observer for WhenData arrives in order to define dynamiclly when loading or loaded is done spin.transform.Find("Text").GetComponent <Text>().text = "Loading Cards.."; SocketController.Send(NetworkInstructions.PLAYER_CARDS_REQUEST, null); //Save the username and pwd if the remmeber is set true if (PlayerPrefs.GetInt("login_remmeber") == 1) { PlayerPrefs.SetString("login_username", usrField.text); PlayerPrefs.SetString("login_password", pwdField.text); Debug.Log("Remmeber saved"); } //Unbind the login handlers since we're going to load the next scene SocketController.UnbindEvent(NetworkInstructions.LOGIN_FAIL); SocketController.UnbindEvent(NetworkInstructions.LOGIN_REQUEST); SocketController.UnbindEvent(NetworkInstructions.LOGIN_SUCCESS); //Wipe notifier list if it gives problems trying to notify here SocketController.UnbindEvent(NetworkInstructions.ServerOffline); //Load next scene SceneManager.LoadSceneAsync("MainMenu"); }); }