Player Zero
  • Welcome
  • Integrations
    • Unity Integration
      • Deeplinking
    • Direct API Integration
Powered by GitBook
On this page
  • Introduction
  • Mobile Deeplinking Setup
  • Android
  • iOS
  • Desktop Deeplinking Setup
  • Windows
  • MacOS
  • Loading avatars via Deeplink
Export as PDF
  1. Integrations
  2. Unity Integration

Deeplinking

PreviousUnity IntegrationNextDirect API Integration

Last updated 1 month ago

Introduction

Deep linking allows your application to respond to external URLs and launch directly into specific content or actions within the app. This is particularly useful for experiences like loading user-specific avatars or jumping into a custom scene from a shared link. Our SDK supports deep linking across mobile platforms (Android and iOS) as well as desktop platforms (Windows and macOS). This guide will walk you through enabling and handling deep links in your Unity project using our SDK.

Mobile Deeplinking Setup

When it comes to sending avatars created in our PlayerZero web platform the simplest way to send them to a mobile application is by passing data via deep linking. Unity supports deeplinking and the steps described below can also be found in the Unity documentation here.

Android

To enable deeplinking for Android you can use an intent filter. The process is as follows:

The steps for this process can also be found on the .

  1. In Unity navigate to Edit > Project Settings > Player

  2. In the Android settings tab, expand the Publishing Settings section

  3. In the Build section, enable Custom Main Manifest. This creates a new file called AndroidManifest.xml in Assets/Plugins/Android.

  4. In the Project window, go to Assets > Plugins > Android and open the AndroidManifest.xml file

  5. Add the following code sample inside the Unity<activity> element, named com.unity3d.player.UnityPlayerGameActivity or com.unity3d.player.UnityPlayerActivity, and save the file.

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:scheme="playerzero0000" android:host="playerzero" /> 
</intent-filter>

Remember to replace the number 0000 in playerzero0000 with your unique GAMEID to ensure you are using your own unique scheme.

iOS

To enable deeplinking for iOS it is even simpler, the process is as follows.

  1. Go to Edit > Project Settings > Player > Other Settings > Configuration.

  2. Expand Supported URL schemes to set the following properties:

    • Size property to 1.

    • Element 0 property to the URL scheme to use with your application. For example, use playerzero0000 to open your application when the device processes a link that starts with playerzero0000://.

Remember to replace the number 0000 in playerzero0000 with your unique GAMEID to ensure you are using your own unique scheme.

Desktop Deeplinking Setup

Windows

  1. Ensure that you have set your GameID by logging into the Player Zero Developer Window located in the tool bar Tools > Player Zero

  2. In your first scene add an empty GameObject and add the component DesktopDeepLinkSetup.

  3. If you look in the components inspector the SetupOnStart property will be enabled by default. If enabled this means that when this scene is run it will automatically create a custom Windows registry that will enable us to launch the application from a web URL.

MacOS

The deeplinking setup process for MacOS is exactly the same as for iOS. In any case you can find the steps below.

  1. Go to Edit > Project Settings > Player > Other Settings > Configuration.

  2. Expand Supported URL schemes to set the following properties:

    • Size property to 1.

    • Element 0 property to the URL scheme to use with your application. For example, use playerzero0000 to open your application when the device processes a link that starts with playerzero0000://.

Remember to replace the number 0000 in playerzero0000 with your unique GAMEID to ensure you are using your own unique scheme.

Loading avatars via Deeplink

Now that we have enabled deeplinking we can make use of the PlayerZeroSdk.OnHotLoadedAvatarIdChanged event.

Lets create a new C# script and call it DeepLinkingSample.

First we will create a load avatar function that uses our PlayerZeroSDK functions to request, download and instantiate the character model.

 public class DeepLinkingSample : MonoBehaviour {    

    public async Task LoadAvatar(string avatarId)
    {
        var response = await PlayerZeroSdk.GetAvatarMetadataAsync(avatarId);
        var characterRequestConfig = new CharacterRequestConfig()
        {
            AvatarId = avatarId,
            AvatarUrl = response.ModelUrl,
            BlueprintId = response.BlueprintId,
            Parent = transform
        };

        var avatarGameObject = await PlayerZeroSdk.InstantiateAvatarAsync(characterRequestConfig);
    }
}

Now we can create a new function that uses the PlayerZeroSDK.HotLoadedAvatarId() to get the avatarId.

public void LoadHotLoadedAvatar()
{
    LoadAvatar(PlayerZeroSdk.GetHotLoadedAvatarId());
}

Now you can use the LoadHotLoadedAvatar() function whenever you want to load the avatar.

Alternatively you can subscribe to the PlayerZeroSdk.OnHotLoadedAvatarIdChanged event which is automatically triggered whenever a new avatar id has been detected.

To do this lets we can use the Awake function subscribe to the OnHotLoadedAvatarIdChanged event and assign a new function that loads the avatar.

private void Awake()
{
    PlayerZeroSdk.OnHotLoadedAvatarIdChanged += OnHotLoadedAvatarIdChanged;
}

private void OnHotLoadedAvatarIdChanged(string avatarId)
{
    LoadAvatar(avatarId);
}

Don't forget to unsubscribe to the event

private void OnDestroy()
{
    PlayerZeroSdk.OnHotLoadedAvatarIdChanged -= OnHotLoadedAvatarIdChanged
}

Below you can find the full sample script.

using System.Threading.Tasks;
using PlayerZero.Runtime.Sdk;
using UnityEngine;

public class DeepLinkingSample : MonoBehaviour
{
    private void Awake()
    {
        PlayerZeroSdk.OnHotLoadedAvatarIdChanged += OnHotLoadedAvatarIdChanged;
    }
    
    private void OnDestroy()
    {
        PlayerZeroSdk.OnHotLoadedAvatarIdChanged -= OnHotLoadedAvatarIdChanged;
    }
    
    private void OnHotLoadedAvatarIdChanged(string avatarId)
    {
        LoadAvatar(avatarId);
    }
    
    public void LoadHotLoadedAvatar()
    {
        LoadAvatar(PlayerZeroSdk.GetHotLoadedAvatarId());
    }
    
    public async Task LoadAvatar(string avatarId)
    {
        var response = await PlayerZeroSdk.GetAvatarMetadataAsync(avatarId);
        var characterRequestConfig = new CharacterRequestConfig()
        {
            AvatarId = avatarId,
            AvatarUrl = response.ModelUrl,
            BlueprintId = response.BlueprintId,
            Parent = transform
        };

        var avatarGameObject = await PlayerZeroSdk.InstantiateAvatarAsync(characterRequestConfig);
    }
}

The steps for this process can also be found on the .

To enable deeplinking for desktop applications on Windows we a custom entry needs to be added to the Window registry. Without this it is not possible to trigger the application to launch from a web URL. For more information on Windows registries including how to add and remove them please refer to the .

The following guide is intended for games that are not going to be published on Steam, if your game or application is going to be published on Steam we recommend using the for app deeplinking as if offers a more robust solution, particularly in regards to deferred deeplinking as it utilizes Steams built in deeplink features.

The steps for this process can also be found on the .

Unity documentation
Unity documentation
Windows documentation
SteamWorks plugin
Unity documentation