Skip to main content
This sample demonstrates a simple PlayFab sign-in flow for Unity. Players can log in with an email and password, create a new account, or continue as a guest. Credentials can optionally be remembered across sessions.

Requirements

Unity 2018.3+

The project was created with Unity 2018.3 and requires that version or later.

Visual Studio 2017+

Visual Studio 2017 (Update 15.7) or later is required to open and build the project.

Android / iOS device

A physical or virtual Android/iOS device provides the best experience.

PlayFab title ID

A valid PlayFab Title ID must be configured before running the sample.

PlayFab configuration

Before running the sample you must supply your PlayFab Title ID. You can do this in one of two ways:
  • Use the PlayFab Editor Extensions for Unity, or
  • Open Assets/PlayFabSdk/Shared/Public/Resources/PlayFabSharedSettings.asset in the Unity Inspector and set the Title ID field directly.

Setup

1

Clone the repository

git clone https://github.com/Myst0gan1/PlayFab-Samples.git
2

Open the project in Unity

In Unity Hub, click Open and navigate to:
PlayFab-Samples/Samples/Unity/PlayFabSignIn
3

Configure your Title ID

Either use the PlayFab Editor Extensions panel, or set the Title ID directly in Assets/PlayFabSdk/Shared/Public/Resources/PlayFabSharedSettings.asset.
4

Open the sample scene

In the Project window, open the scene located in Assets/Scenes/.
5

Enter Play mode

Press Play in the Unity Editor. A sign-in dialog appears. Use an existing account, create a new one, or sign in as a guest.

Using the sample

After launch you are prompted to sign in. The available options are:
  • Email / password login — authenticate with an existing PlayFab account.
  • Create account — register a new account with an email and password.
  • Guest login — sign in anonymously without credentials.
  • Remember me — persist sign-in info so the dialog is skipped on the next run.
Once signed in, you can clear sign-in data or the remembered session from the post-login screen.

Code structure

All scripts live in Assets/Scripts/, split into two sub-folders:
FileResponsibility
PlayFabAuthService.csEncapsulates all PlayFab authentication calls: anonymous login, email/password login, account registration, and session-token persistence.
FileResponsibility
LoginWindowView.csDrives the sign-in dialog, binds UI events to PlayFabAuthService, and manages the “remember me” toggle state.

Key PlayFab features

LoginWithEmailAddress

Authenticates a returning player using their email and password.

RegisterPlayFabUser

Creates a new account with email, password, and optional display name.

LoginWithCustomID

Provides anonymous guest login via a device-generated custom ID.

Session persistence

Saves the session ticket locally so players are not prompted again on subsequent runs.

Build docs developers (and LLMs) love