- Home /
Use variable from another script with WWW give NULL?
Hi, I'm trying to use a variable from another script attached to "Main Camera". I do get the variable to output correctly on Debug.Log and GUI.Label but I can't get it to work with WWW...
EDIT NOTE: At this point I have already successfully logged in with the Wusername. I'm trying to query another DB with a already successfully used variable.
public string Wusername;
Wusername = GameObject.Find("Main Camera").GetComponent<login>().userNameGet;
WWWForm form = new WWWForm();
form.AddField(Wusername, Wusername);
form.AddField("securityKeyGetCharInfo", securityKeyGetCharInfo);
WWW GetCharacterAPI = new WWW(secureKeyGetCharInfoURL, form);
StartCoroutine(GetCharacter(GetCharacterAPI));
The web page is receiving Wusername as null. What could I do to fix this?
I want this to be able to work without having to type it in a textfield again. If it can't be done I'd like to know another way to do this.
Thanks in advance for your time and help! :)
do you mean on line 6 for it to be
form.AddField("username", Wusername);
Answer by ByteVault · Mar 21, 2014 at 05:24 PM
A slight typo. With a fresh mind which had gotten It's sleep found the problem to be the missing quotes.
form.AddField("Wusername", Wusername);
This works as intended now and I will keep fixing. Thanks JChilton, sorry I missed it!
:c thanks for acknowledging me 20 $$anonymous$$utes ago lol
Oh, really.. Sorry dude. I never got the mail saying someone commented! Sure, you were right though. Thanks for the help!