FractalLoginButton prefab is recommended to handle the authentication process across all platforms.
This includes displaying the login prompt in the browser and subsequently verifying the authentication when the user
returns into the game.
- On desktop & mobile builds the default browser displays the authentication prompt. The player session is verified when returned to the game instance.
- On WebGL builds the authentication prompt is displayed in a popup without exiting the game session.
Integrating the prefab in your game will help you set up the Fractal wallet login in under a minute.
Add prefab to the scene
FractalLoginButton prefab to your game scene from the
FractalLoginButton prefab should be nested inside
UI > Canvas object. This will automatically
create Fractal sign in button on your scene's UI layer. You can customize the button as needed.
Configure the authentication
When selecting the prefab from the scene hierarchy, notice that the object contains the
Fractal Login Handler script
inside the object Inspector.
Here you can configure the login process as needed:
- Enter your project's API key (client id), obtained from Fstudio.
- Select the required API scopes.
- Attach to 3 available events,
OnStarted, OnLogin, OnError, to customize the authentication behavior.
Verify the setup
You are all set up with the Fractal login. Verify by playing your scene in the Unity editor. SDK will log all of the outputs into the console, conveniently tagged with a [FRACTAL].
If everything works and you can see authenticated user's id, you can now call
FractalClient to access user wallet across all scenes and objects. If you have issues specific to WebGL build, follow the additional project set up in the previous page.
If you plan to structure your scene differently or want to use a completely custom login button, you can use
/FractalSDK/Scripts/FractalLoginHandler script and add it as a component to any object in your scene. You can set a target button in the Inspector to execute the authentication process.