- Home /
Variable from Inputfield is being updated but when I go to use it, its empty sting
So Like Question says. I am making a Login menu using Playfab. I had it all working and then OCD me decided to organize code and broke something. So I have a password Inputfield that calls a method to set the password variable. I placed a debug.Log right under the userPassword = passwordIn which in play mode I can see updating as I type in the inputfield. When I go to call the Loginwithemail API with the OnclickLoginButton It keeps saying it empty. I also placed another Debug>log right before the login api gets called and its blank.
Here is the OnClickLogin Method
public void OnClickLogin()
{
Debug.Log("UserPassword is: " + userPassword);
var request = new LoginWithEmailAddressRequest { Email = userEmail, Password = userPassword };
PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
if (rememberUser)
{
PlayerPrefs.SetInt("RememberUser", rememberUser ? 1 : 0);
}
}
And here is the GetUserPassword Method... very basic
public void GetUserPassword(string passwordIn)
{
userPassword = passwordIn;
Debug.Log("UserPassword is now: " + userPassword);
}
Here is a shot of the password Inputfield setup
As I mentioned. In the console I can see the variable being updated as I type into the InputFiled. But soon as the debug gets called inside the OnLCickLogin method its blank. I have been searching google for around an hour now and cant find a solution.
UPDATE-- Just tinkering around and made an update method for a debug.Log where I show user email and password. Both variables are getting updated when I type into the inputfield. But soon as I click on the login button they both are empty strings.
Answer by technorocker · Feb 04, 2020 at 08:13 PM
So I ended up re-setting the email and password at the top of the OnClickLogin method and thats getting the password. But why do I have to set it again.
I am running into this exact problem with the username variable now for a different part of the login process. Am I missing something. I call a debug.log in multiple places and it shows up in some but not others even AFTER it clearly shows the string variable has been set to the username.
Can someone please share your knowledge on why the variable is not called properly?
Your answer
Follow this Question
Related Questions
On Click, increment variable 1 Answer
Calling a variable in C#? 1 Answer
'Cannot convert int to String' 2 Answers
how do I find components through variable 1 Answer
Variable is always false... 1 Answer