Unity
Unity integration
Introduction
Guest Login/Logout
Subscribe Authentication Changed event
using RGN;
using RGN.Modules.SignIn;
using UnityEngine;
public class AuthenticationChangedController : MonoBehaviour
{
private void OnEnable()
{
RGNCore.I.AuthenticationChanged += OnAuthenticationChangedAsync;
}
private void OnDisable()
{
RGNCore.I.AuthenticationChanged -= OnAuthenticationChangedAsync;
}
private async void OnAuthenticationChangedAsync(AuthState authState)
{
switch (authState.LoginState)
{
case EnumLoginState.Success:
Debug.Log("User is logged in");
// You can start retrieving some data here
break;
case EnumLoginState.NotLoggedIn:
Debug.Log("User is not logged in");
break;
case EnumLoginState.Error:
Debug.LogError("On Auth error: " + authState.LoginState +
", error: " + authState.LoginResult);
break;
default:
Debug.LogError("Unhandled Login State: " + authState.LoginState);
break;
}
}
}