arrow-left

All pages
gitbookPowered by GitBook
1 of 3

Loading...

Loading...

Loading...

Unreal

Unreal integration

Introduction

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.

hashtag
Guest login

By default, the project is configured to automatically log into a guest account. This feature is enabled in the plugin settings.

If you require more control over this process, you can disable the checkbox and manually manage guest account logins.

hashtag
Email login

Email login posted by Car3manPLAY | blueprintUE | PasteBin For Unreal Engineblueprintuechevron-right
Guest login posted by Car3manPLAY | blueprintUE | PasteBin For Unreal Engineblueprintuechevron-right
Logo
Logo

Authentication

Integration Guide

Unity

Unity integration

hashtag
Introduction

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.

hashtag
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.

hashtag
Subscribe Authentication Changed event

hashtag
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();
    }
}
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;
        }
    }
}