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;
}
}
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);
ok, but i have error Assets/name.cs(13,17): error CS0029: Cannot implicitly convert type void' to
string'
$$anonymous$$y bad, I was seeing Label but thinking InputField and making weird assumptions.
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";
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);
ok, but i have error, in gui label show aaa text :S why ?
if ($numrows == 0) {
echo"aaa";
}
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'
Your answer
Follow this Question
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