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 /
  • Help Room /
avatar image
0
Question by trjfjfgjf · Oct 27, 2016 at 08:11 PM · loginmysqlphp

warning CS0649: Field `name.username' is never assigned to, and will always have its default value `null'

i want show username in gui label from mysql database in another scene after login succes.. but nothing diplayed sry for english

 using UnityEngine;
 using System.Collections;
 
 
 public class name : MonoBehaviour {
 
     string username;
     string password;
 
 
     void OnGUI(){
 
         GUI.Label(new Rect(826,251,70,40) , username);
 
     }
 
     void Start(){
 
 
         StartCoroutine (registerFunc (username,password));
 
     }
 
     IEnumerator registerFunc (string username, string password)
     {
         string url = "http://localhost/tester/login.php";
         WWW www  = new WWW(url);
         yield return www;
         username = www.text;
 
     }
 }
Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by alexpizzini · Oct 27, 2016 at 08:16 PM

The function GUI.Label() returns a string value that should be the new value of your username field. Right now, you're not actually changing the value of username. In other words, it's never being assigned to.

 username = GUI.Label(new Rect(826,251,70,40) , username);
Comment
Add comment · Show 3 · 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
avatar image trjfjfgjf · Oct 27, 2016 at 08:19 PM 0
Share

ok, but i have error Assets/name.cs(13,17): error CS0029: Cannot implicitly convert type void' to string'

avatar image alexpizzini · Oct 27, 2016 at 09:01 PM 0
Share

$$anonymous$$y bad, I was seeing Label but thinking InputField and making weird assumptions.

avatar image trjfjfgjf alexpizzini · Oct 27, 2016 at 09:10 PM 0
Share

Ok, i use 3d text mesh and its ok but result is weird i get echo message from php script if ($numrows == 0) {

echo"aaa";

} http://i67.tinypic.com/2ai2614.png

avatar image
0

Answer by AurimasBlazulionis · Oct 27, 2016 at 08:17 PM

Avoid using the same variable names locally in functions as the global ones. Inside IEnumerator, change username and password to something like user and pass. Not much can be done with this much of information.

Also, you are not setting username to anything at all. Change GUI.Label(new Rect(826,251,70,40) , username); to username = GUI.Label(new Rect(826,251,70,40) , username);

Comment
Add comment · Show 1 · 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
avatar image trjfjfgjf · Oct 27, 2016 at 08:53 PM 0
Share

ok, but i have error, in gui label show aaa text :S why ?

if ($numrows == 0) {

 echo"aaa";
 

}

avatar image
0

Answer by trjfjfgjf · Oct 27, 2016 at 08:33 PM

tnx .. i have error Assets/name.cs(13,17): error CS0029: Cannot implicitly convert type void' to string'

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

78 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using POST and WebRequest in Unity 0 Answers

Unity sql PHP script can log in with wrong password, what's wrong? 0 Answers

WWW not working on my PHPs 0 Answers

how to save value to mysql 1 Answer

Money from unity to mysql db 0 Answers


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