Configure your Unity project
Learn how to configure your Unity project
To configure your Unity project, you need to:
- Import the Stash package.
- Configure deep links and URL schemes.
- Extract the code challenge.
1. Import the Stash package
To import the Stash package:
- Download the latest Stash for Unity release.
- Import the
.unitypackage
file into your game using the local asset package import process. - Optionally select the
Scenes
folder to import demo scenes.
2. Configure linking
Universal links and deep links allow you to send users to specific locations within your game instead of a website. You need to configure these so that players can launch your game from the web shop and complete the account linking process. Due to recent platform updates, Stash recommends using universal links instead of deep links because they support better compatibility.
With deep links, you have to register a custom protocol such as stashggsample://
. But with universal links, you can use a verified website domain such as stash.gg/launch
to launch your game and process the code linking challenge. If players don't have your game installed, your game's website is opened instead which is a better player experience.
Set up universal links (recommended)
The Unity Editor doesn't have built-in support for universal links so some configuration is required. For Android, you need to create a custom AndroidManifest.xml
to set up the intent filter. On iOS, you can configure the associated domains in your Xcode project.
You also need to set up App Links in the Google Play Console and App Store Connect and verify your domain. The target URL also needs to exist and needs to be accessible because it acts as a fallback if the game isn't installed on the device. Follow the official documentation for more details:
Set up deep links
Unity's documentation has a deep linking overview, as well as platform-specific instructions:
URL schemes
Stash's URL schemes look like this:
https://stash.gg/://link?challenge=QBHb5sIdj5RpEJTYZU2_mxUDLml1PRbd0Io5I2g8oVg
stashggsample://://link?challenge=QBHb5sIdj5RpEJTYZU2_mxUDLml1PRbd0Io5I2g8oVg
The verified domain URL (for universal links) and custom protocol (for deep links) are unique identifiers agreed upon between you and Stash and can be configured in Stash Studio. The content of the entire link is passed to the game binary when the game is launched. The code challenge is then used to complete the account linking process within the game.
3. Extract the code challenge
With deep linking configured, you can extract the code challenge. There's an example below but you should use Unity’s Application.deepLinkActivated
event and their deep linking documentation to complete the process.
The onDeepLinkActivated
event handler is invoked every time the game is launched or resumed using Stash’s deep link. The link is then split and the code challenge is extracted.
public void onDeepLinkActivated(string url) {
// Extract the challenge parameter from the link.
var challenge = url.Split("/link?challenge=")[1];
if (!string.IsNullOrEmpty(challenge)) {
// Work with code challenge...
}
}
Updated 4 months ago