Unity SDK
Install and configure Hardal for your Unity games
For hands-on tutorial, you may want to take a look to our blog
Installation
The Hardal SDK can be installed via Unity Package Manager:
-
Add the package to your project via Package Manager
-
Or add the following line to your
manifest.json
:
Setup
Option A: Using the Menu Item
-
In Unity Editor, go to
GameObject > Hardal > Create Hardal Manager
-
This will create a new GameObject with HardalManager component
-
In the Inspector, set your endpoint URL
-
Optionally enable debug logs
Option B: Manual Setup
-
Create an empty GameObject in your scene
-
Add the HardalManager component to it
-
Configure the endpoint URL in the Inspector
-
The GameObject will persist between scenes
Basic Usage
Initialize Hardal
Track Events
Debug Mode
Enable debug logging in the Inspector to see detailed information about:
-
Initialization status
-
Event tracking
-
Network requests
-
Errors and warnings
To enable debug mode:
-
Select the HardalManager GameObject
-
Check “Enable Debug Logs” in the Inspector
-
View logs in the Unity Console with “[Hardal]” prefix
Example Usage
Basic Implementation
Advanced Implementation
Important Notes
-
Only one instance of HardalManager should exist in your project
-
The manager persists between scenes using DontDestroyOnLoad
-
Always check if the SDK is initialized before tracking events
-
Use try-catch blocks when working with async methods
-
Enable debug logs during development for better visibility
Best Practices
-
Initialize the SDK early in your game lifecycle
-
Use meaningful event names
-
Be consistent with property names
-
Handle async operations properly
-
Test with debug mode enabled during development
Was this page helpful?