To interact with the PLAY API, you will need to be authenticated. This will allow you to store and retrieve additional user data in the PLAY ecosystem.
Guest Login/Logout
If the Auto Guest Login option in RGNUnityInitilizer.cs is checked, logging out from email will automatically sign you back in as guest.
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;
}
}
}
Email Login/Logout
using RGN.Modules.SignIn;
public class EmailLoginLogout : MonoBehaviour
{
public void EmailSignIn()
{
// This call will open a web form
// Handle the result in RGNCore.I.AuthenticationChanged event callback
EmailSignInModule.I.TryToSignIn();
}
public void EmailSignOut()
{
EmailSignInModule.I.SignOut();
}
}