Unity SDK
Resolve public links and send attributed outcomes with Unity coroutines.
Choose this SDK when#
Use the Unity SDK for games or interactive applications built with Unity 2021.3 or later where a MonoBehaviour owns link routing.
Warning
Version 0.1.3 is source-only. Unity Editor compilation and signed-device opening are not yet published proof; pin evaluations to a reviewed commit SHA.Choose another SDK when: your mobile shell is implemented outside Unity or you require a registry-published package. Route links in the owning native shell instead.
Before you start#
- Unity 2021.3 or later and a reviewed LocusVia repository commit.
- A LocusVia App Platform ID and environment-scoped SDK key.
- A routing function that can translate the resolved pathname into a Unity scene or application state.
Note
Use an environment-scoped public SDK key. Never embed a server, admin, or privileged credential in an app.1. Add the package#
In Unity Package Manager choose Add package from git URL. Pin the URL to the reviewed commit you tested.
https://github.com/NanFengCheong/locusvia.git?path=/sdk/unity#REVIEWED_COMMIT_SHA2. Create the client#
Use the API origin, not the public link domain. Create one client and keep it with the application shell.
var client = new LocusViaClient(new LocusViaConfig(
"REPLACE_WITH_APP_ID",
"REPLACE_WITH_SDK_KEY",
"https://staging.locusvia.com"));3. Resolve and route#
Start the coroutine from a MonoBehaviour. Route only when the response contains a link pathname; keep failures visible in development logs.
StartCoroutine(client.ResolveShortLink(
receivedUrl,
result => {
if (result.processed && result.link != null) Route(result.link.pathname);
},
Debug.LogWarning));4. Track the outcome#
Use a stable event ID and an uppercase three-letter currency. Never sum or relabel different currencies in the client.
StartCoroutine(client.TrackOutcome(
"purchase",
19.99m,
"USD",
completed: response => Debug.Log(response.accepted),
failed: Debug.LogWarning));Verify the integration#
- Run the package EditMode tests for the reviewed source revision.
- Open a public link in an actual player build and confirm the expected scene or route receives the pathname.
- Send the same stable outcome event ID twice and confirm the server does not double-count it.
Warning
A successful build proves source compatibility only. Test a real link on the target browser or signed device before release.Troubleshoot by symptom#
Next steps#
Confirm your domain associations, then add conversion and revenue events only after link resolution works end to end.