Answer the question
In order to leave comments, you need to log in
How to do authorization?
Made a sort of simple authorization (extra code removed)
public class Authorization : MonoBehaviour{
..................
void Start(){
if(PlayerPrefs.HasKey("Login") && PlayerPrefs.HasKey("Password")){
LoginField.text = PlayerPrefs.GetString("Login");
PasswordField.text = PlayerPrefs.GetString("Password");
EnterGame();
}
}
public void EnterGame(){
StartCoroutine(AuthorizationGame());
}
IEnumerator AuthorizationGame(){
WWWForm form = new WWWForm();
form.AddField( "login", LoginField.text);
form.AddField( "password", PasswordField.text);
UnityWebRequest www = UnityWebRequest.Post(ServerIpAddress, form);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError){
Answer="error";
}else{
Answer=www.downloadHandler.text;
......................
PlayerPrefs.SetString("Login", LoginField.text);
PlayerPrefs.SetString("Password", PasswordField.text);
SceneManager.LoadScene("Game");
}
}
}
Answer the question
In order to leave comments, you need to log in
Zimaell ,
1) Where do you see errors? You need to look in the log file that is next to the exe, and not in the editor.
2) Add Debug.Log("1...n") between lines of code to understand which step is passing and which is not.
3) Add a response log from the server (data and response code)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question