Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by BrennanVargas1 · Jul 18, 2011 at 05:57 AM · errorstringbooleansyntax-errorcs0029

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.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dreamblur · Jul 18, 2011 at 06:46 AM 0
Share

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".

avatar image Waz · Jul 18, 2011 at 06:56 AM 0
Share

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.

avatar image BrennanVargas1 · Jul 18, 2011 at 07:52 AM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by BrennanVargas1 · Jul 18, 2011 at 07:53 AM

This has already been solved

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges