- Home /
Login String to Bool Errors
I dont exactly see why im getting these errors but i would much appreciate it if i got some help on this.
Here are the errors...
Assets/My Assets/Scripts/Network/MultiPlayer/Login.cs(27,17): error CS0029: Cannot implicitly convert type `string' to `bool'
Assets/My Assets/Scripts/Network/MultiPlayer/Login.cs(33,17): error CS0029: Cannot implicitly convert type `string' to `bool'
Here is my simple login script (its only temporary but it might be a base)...
using UnityEngine; using System.Collections;
public class Login : MonoBehaviour {
public string UserName = "UserName";
public string passwordToEdit = "My Password";
public bool isUserNameCorrect = false;
public bool isPasswordCorrect = false;
public bool UserNameFilled = false;
public bool PasswordFilled = false;
public bool PasswordCheckFilled = false;
public bool EmailFilled = false;
public bool EmailCheckFilled = false;
public string CheckIfBot;
public bool CheckIfBotCorrect = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void OnGUI () {
if(GUI.TextField(new Rect(Screen.width / 2, (Screen.height / 2), 200, 20), UserName)){
if(UserName == PlayerPrefs.GetString(UserName)){
isUserNameCorrect = true;
}
}
if(GUI.PasswordField(new Rect(Screen.width / 2, (Screen.height / 2) - 50, 200, 20), passwordToEdit, "*" [0], 25)){
if(passwordToEdit == PlayerPrefs.GetString(passwordToEdit)){
isPasswordCorrect = true;
}
}
if(GUI.Button(new Rect((Screen.width / 2) + 50, (Screen.height / 2) - 100, 125, 25), "Login")){
if(isUserNameCorrect == true | isPasswordCorrect == true){
Application.LoadLevel(1);
}
}
}
}
I know there are variables that are unused atm but i like to complete a section of a script completely at a time so that would be why those arent being used.
GUI.TextField and GUI.PasswordField both return a string but you're using them as conditional statements. That's like being asked "Do I look fat?" and responding with "Canada".
And the next lines make about as much sense. I really think you need to read the docs for GUI.TextField and PlayerPrefs.GetString, rather than just throwing lines together and posting the compiler output here.
sorry im tired didnt really realize what i was doing but i figured out a different way of doing this thanks, lmao i laugh at Dreamblurs answer
Your answer
Follow this Question
Related Questions
Compile Errors for Script 1 Answer
help with a random battle generator? 2 Answers
Quiz Scoreboard 2 Answers
Getting list music array 1 Answer
Error CS0029 fix 1 Answer