Deeplinking
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. 🎥 Prefer to watch instead? This short video (2 minutes) walks you through how to set up mobile deep linking using the PlayerZero SDK in Unity on both Android and iOS.
Android
To enable deeplinking for Android you can use an intent filter. The process is as follows:
In Unity navigate to Edit > Project Settings > Player
In the Android settings tab, expand the Publishing Settings section
In the Build section, enable Custom Main Manifest. This creates a new file called
AndroidManifest.xml
inAssets/Plugins/Android
.In the Project window, go to Assets > Plugins > Android and open the
AndroidManifest.xml
fileAdd the following code sample inside the Unity
<activity>
element, namedcom.unity3d.player.UnityPlayerGameActivity
orcom.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.
Go to Edit > Project Settings > Player > Other Settings > Configuration.
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 withplayerzero0000://
.

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
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 Windows documentation.
Ensure that you have set your GameID by logging into the Player Zero Developer Window located in the tool bar Tools > Player Zero
In your first scene add an empty GameObject and add the component DesktopDeepLinkSetup.
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.
Go to Edit > Project Settings > Player > Other Settings > Configuration.
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 withplayerzero0000://
.

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);
}
}
Last updated