- Home /
can i get help with a minor debug please ?
in short, I'm following a tutorial on Lynda in which I'm creating a firebase to help with user logins in my app. in the process of adding the option to log in with an email address and password however I'm having issues with linking the code functions from the script into the properties of the specific objects in my unity project (images will show what i mean) Going to copy and paste script as this forum won't let me upload image of it.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Firebase; using Firebase.Auth;
public class FormManager : MonoBehaviour {
// UI objects linked from the inspector
public InputField emailInput;
public InputField passwordInput;
public Button SignUpbutton;
public Button LoginButton;
public Text statusText;
public Authmanager authmanager;
private void Awake()
{
ToggleButtonStates(false);
// auth delegate subscriptions
authmanager.authCallback += HandleAuthCallback;
}
/// <summary>
/// Validates the email input
/// </summary>
public void ValidateEmail()
{
string email = emailInput.text;
var regexPattern = @"^(([\w ]+\.)+[\w ]+|([a zA-Z]{1}|[\w ]{2,}))@"
+ @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5}|2[0-4][0-9](\."
+ @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5}|2[0-4][0-9])){1}|"
+ @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})S";
if (email != "" && Regex.IsMatch(email, regexPattern))
{
ToggleButtonStates(true);
}
else
{
ToggleButtonStates(false);
}
}
//firebase methods
public void Onsignup()
{
authmanager.SignUpNewUser(emailInput.text, passwordInput.text);
Debug.Log("sign up");
}
public void OnLogIn()
{
Debug.Log("Login");
}
IEnumerator HandleAuthCallback(Task<Firebase.Auth.FirebaseUser> task, string operation)
{
yield return null;
if (task.IsFaulted || task.IsCanceled)
{
Updatestatus("sorry, there was an error creating your new account. Error: " + task.Exception);
}
else if (task.IsCompleted)
{
Firebase.Auth.FirebaseUser newPlayer = task.Result;
Updatestatus("loading the game scene");
}
}
private void OnDestroy()
{
authmanager.authCallback -= HandleAuthCallback;
}
// Utilities
private void ToggleButtonStates(bool toState)
{
SignUpbutton.interactable = toState;
LoginButton.interactable = toState;
}
private void Updatestatus(string message)
{
statusText.text = message;
}
}
@miggsta10 did you find a solution for this? I'm working through the same tutorial now and cannot figure out how to run the coroutine from inside the task thread he has setup for this part as well as the authCallback. It works for him somehow, which is extra confusing. Any help is greatly appreciated!
Answer by H1ddeNGames · Dec 27, 2018 at 11:19 AM
If the method you're looking to give to that On Click() isn't showing up, that means it's a method that does not return void or it's a method that takes in an unsupported parameter. As far as I know only string and int parameters work and you may only have on parameter when you want to make a button run a user made function.
Answer by a5216276 · May 20, 2019 at 06:28 AM
I am running "Task task" and there will be an error. Do you have a similar situation?