Verisoul Docs
Search
K

WebGL

If you are building for WebGL you'll need to add the following line to the index.html so that the browser javascript can communicate with Unity.
To automate this process you can create a WebGL Custom Build Template; otherwise you'll need to add this line on every build for version < Unity 2021.
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + "%";
}).then((unityInstance) => {
// add this line
window.unityInstance = unityInstance;
loadingBar.style.display = "none";
fullscreenButton.onclick = () => {
unityInstance.SetFullscreen(1);
};
}).catch((message) => {
alert(message);
});
};

Pilot Usage

After the user is authenticated in your system call the OnAuth function to and pass a join key with an account identifier.
#region auth
private void WhenUserIsAuthenticated(accountId)
{
VerisoulManager.Instance.OnAuth(accountId);
}

Production Usage

In order to ensure adequate security, for production you'll need to pass the accountId via backend API call to Verisoul's API. You can use GetTrackingId to get the current client trackingId and join it with the accountId via API Call.
private void HandleVerisoulEvent(VerisoulEventType type, string message, string error)
{
if (error.Length > 0)
{ /* handle error */ }
switch (type)
{
case VerisoulEventType.GetTrackingId:
string trackingId = message;
using (var client = new HttpClient())
{
try
{ // pass trackingId to backend
// to make a secure call to Verisoul API
string myApiUrl = $"https://example.com/your-backend-api/{trackingId}";
HttpResponseMessage response = await client.GetAsync(myapiUrl);
response.EnsureSuccessStatusCode();
}
catch (Exception ex)
{ /*handle exception*/ }
}
break;
// ...
}
}