Unity SDK
Attriax already exposes a Unity runtime track for scene-aware attribution and deep-link handling, but we still treat it as an in-development public integration surface.
Package surface
General guide for Attriax Unity package. Use the project workspace when you need detailed setup steps, release context, and project-specific values.
What teams use it for
These are the runtime jobs the product already exposes through the SDK and the matching workspace tools.
Scene-aware runtime
Keep attribution, app-open tracking, and scene context together in the engine lifecycle.
Validator-backed setup
Use the editor validator and setup diagnostics once the package is imported into a real project.
Maturing release track
Documented today, improving over time, and best paired with the project workspace for current release details.
Integration notes
Keep the public docs lightweight, then open the project workspace when you need the exact setup steps for your own release flow.
Capabilities
- Initialize from configured settings or bootstrap a host dynamically when you need a code-first setup path.
- Subscribe to deep-link events and resolve destinations after the runtime finishes app-open processing.
- Enable GDPR-aware delivery with GdprEnabled and use Attriax.Consent.Gdpr from privacy or settings flows.
- Track scene or gameplay context as runtime events so attribution stays connected to in-game behavior.
- Run editor-side validation after import to confirm token and host resolution during setup.
Notes
- Unity is publicly documented here, but the release track is still maturing compared with Flutter and web.
- Unity Editor and desktop players do not register uninstall tokens directly, so token bridges should stay behind mobile runtime checks.
- Create a project to access the current package release details, notes, and validator workflow from the signed-in setup surface.
Distribution
Example
The snippet below mirrors the project workspace starting point while keeping the guide general instead of project-specific.
Assets/Scripts/AttriaxBootstrap.cs
Initialize the runtime, subscribe to deep links, track scene context, and hand resolved destinations back to your game flow.
1#nullable enable
2using System;
3using System.Collections.Generic;
4using System.Threading.Tasks;
5using Attriax.Unity;
6using UnityEngine;
7using UnityEngine.SceneManagement;
8
9public sealed class AttriaxBootstrap : MonoBehaviour
10{
11 private Attriax? _attriax;
12 private IDisposable? _deepLinkSubscription;
13
14 private async void Start()
15 {
16 if (Attriax.HasConfiguredSettings)
17 {
18 _attriax = await Attriax.InitializeConfiguredAsync();
19 }
20 else
21 {
22 var host = await AttriaxBehaviour.CreateAndInitializeHostAsync(
23 new AttriaxConfig
24 {
25 ProjectToken = "ax_your_project_token",
26 GdprEnabled = true,
27 EnableDebugLogs = Debug.isDebugBuild,
28 AutomaticSceneTracking = true,
29 SdkMetadata = new Dictionary<string, object>
30 {
31 ["environment"] = Application.platform.ToString(),
32 },
33 },
34 new AttriaxInitOptions
35 {
36 CaptureInitialUrl = true,
37 },
38 persistAcrossScenes: true);
39
40 _attriax = host.Instance ?? throw new InvalidOperationException(
41 "Attriax host did not create an SDK instance.");
42 }
43
44 if (_attriax == null)
45 {
46 return;
47 }
48
49 _deepLinkSubscription = _attriax.DeepLinks.Stream.Subscribe(HandleDeepLinkEvent);
50
51 var initialDeepLink = await _attriax.DeepLinks.WaitForInitialDeepLink;
52 var originalInstallReferrer = await _attriax.Referrer.GetOriginalInstallReferrerAsync();
53 var reinstallReferrer = await _attriax.Referrer.GetReinstallReferrerAsync();
54 var appOpen = await _attriax.WaitForAppOpenTrackingAsync();
55 if (appOpen != null)
56 {
57 Debug.Log(quot;[Attriax] Install state: {appOpen.InstallState}");
58 }
59
60 if (originalInstallReferrer != null)
61 {
62 Debug.Log(quot;[Attriax] Original install campaign: {originalInstallReferrer.Campaign}");
63 }
64
65 if (reinstallReferrer != null)
66 {
67 Debug.Log(quot;[Attriax] Reinstall campaign: {reinstallReferrer.Campaign}");
68 }
69
70 if (initialDeepLink?.Found == true)
71 {
72 OpenDeepLink(initialDeepLink.Uri.AbsolutePath);
73 }
74
75 await _attriax.TrackEventAsync("session_started", new AttriaxTrackEventOptions
76 {
77 EventData = new Dictionary<string, object>
78 {
79 ["scene"] = SceneManager.GetActiveScene().name,
80 },
81 });
82
83 // Forward mobile uninstall tokens from your native bridge after the SDK is ready.
84 // Example hooks:
85 // NativePushBridge.FirebaseTokenReceived += token => _ = RegisterFirebaseTokenAsync(token);
86 // NativePushBridge.ApplePushTokenReceived += token => _ = RegisterApplePushTokenAsync(token);
87 }
88
89 private void OnDestroy()
90 {
91 _deepLinkSubscription?.Dispose();
92 }
93
94 private void HandleDeepLinkEvent(AttriaxDeepLinkEvent deepLinkEvent)
95 {
96 if (!deepLinkEvent.Found)
97 {
98 return;
99 }
100
101 OpenDeepLink(deepLinkEvent.Uri.AbsolutePath);
102 }
103
104 public async Task RegisterFirebaseTokenAsync(string? token)
105 {
106 if (_attriax == null)
107 {
108 return;
109 }
110
111 await _attriax.RegisterFirebaseMessagingTokenAsync(
112 token,
113 new Dictionary<string, object>
114 {
115 ["provider"] = "fcm",
116 ["platform"] = Application.platform.ToString(),
117 });
118 }
119
120 public async Task RegisterApplePushTokenAsync(string? token)
121 {
122 if (_attriax == null)
123 {
124 return;
125 }
126
127 await _attriax.RegisterApplePushTokenAsync(
128 token,
129 new Dictionary<string, object>
130 {
131 ["provider"] = "apns",
132 ["platform"] = Application.platform.ToString(),
133 });
134 }
135
136 private void OpenDeepLink(string path)
137 {
138 Debug.Log(quot;[Attriax] Navigate to: {path}");
139 // Map the Attriax path to your scene, router, or gameplay flow.
140 }
141}