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;
}
}
