private IEnumerator ProfileRequest(string token) { UnityWebRequest requestProfile = UnityWebRequest.Get("https://unitrivia.herokuapp.com/api/profile"); requestProfile.SetRequestHeader("jwt", token); yield return(requestProfile.SendWebRequest()); if (requestProfile.result == UnityWebRequest.Result.ConnectionError) { Debug.Log("ERROR CONNECTION:" + requestProfile.result); ErrorDataScript.setErrorText("Error de conexión"); ErrorDataScript.setButtonMode(1); SceneManager.LoadScene("Error Scene", LoadSceneMode.Additive); } else if (requestProfile.responseCode != 200) { Debug.Log("ERROR PROFILE:" + requestProfile.downloadHandler.text); ErrorReturn result = ErrorReturn.CreateFromJSON(requestProfile.downloadHandler.text); ErrorDataScript.setErrorText(result.message); ErrorDataScript.setButtonMode(1); SceneManager.LoadScene("Error Scene", LoadSceneMode.Additive); } else { Debug.Log("EXITO PROFILE:" + requestProfile.downloadHandler.text); ProfileReturn result = ProfileReturn.CreateFromJSON(requestProfile.downloadHandler.text); // Save player data UserDataScript.setInfo("token", token); UserDataScript.setInfo("username", result._id); UserDataScript.setInfo("email", result.mail); UserDataScript.setInfo("question", result.preg); UserDataScript.setInfo("answer", result.res); UserDataScript.setInfo("avatar", result.avtr); UserDataScript.setInfo("banner", result.bnr); UserDataScript.setInfo("ficha", result.fich); UserDataScript.setCoins(result.cns); UserDataScript.setStats(result.nj, result.ng); UserDataScript.setItems(result.rfs); SceneManager.LoadScene("Menu Scene", LoadSceneMode.Single); } }