Unity SDK
Welcome to the LicenseSpring Unity beta SDK! This guide will help you understand and use the Unity SDK sample application.
1. Introduction
Where to download?
What is the LicenseSpring Unity SDK?
The LicenseSpring Unity SDK is a software licensing solution that integrates with Unity projects. It enables you to:
Activate and validate software licenses
Manage floating licenses for concurrent usage
Track license consumption and usage
Implement offline (air-gapped) activation
Store license data securely on the local device
Generate hardware-based device fingerprints
This SDK was tested on .NET Standard 2.1 framework, ensuring compatibility with Unity's scripting backend and IL2CPP (Intermediate Language to C++) compilation.
What Does This Sample Demonstrate?
The UnitySample project is a fully functional demonstration that shows:
How to initialize the SDK
License activation with a license key
License validation and checking
License deactivation
Floating license borrowing and release
Consumption tracking for usage-based licenses
Device variable management
Working with local license file storage
This sample provides a complete UI that lets you test all these features interactively, and is easily expandable should you wish to test additional features yourself.
2. Prerequisites
Before you begin, ensure you have:
Unity Hub installed (download from https://unity.com/download)
Unity version 6000.2.9f1 (or a compatible version)
This is the Unity LTS (Long Term Support) version
You can install it through Unity Hub
This demo was created using this Unity version
LicenseSpring Account Credentials:
API Key
Shared Key
Product Code (create a product on the LicenseSpring platform)
These are provided by your LicenseSpring account administrator. You'll need to provide these in the Config.cs file (see Section 6).
Basic Unity knowledge is helpful but not required — this guide will walk you through the process of setting up the Unity sample step-by-step.
3. Opening the Project
Opening the Main Scene
The sample project includes an editor script (
DefaultSceneLoader.cs) that automatically opens the main scene (SampleScene.unity) when you first load the project.If you ever need to manually open the scene:
In the Unity Editor, locate the Project window (bottom/right panel, next to the Console window)
Navigate to: Assets > Scenes
Double-click "SampleScene.unity"
4. Project Structure
SDK DLL Location
LicenseSpring SDK DLL and dependencies are located in Assets/Plugins/LicenseSpring/
This folder contains:
LicenseSpring.dll — The main SDK library with all licensing functionality
LicenseSpring.xml — API documentation for IntelliSense in Visual Studio
hardware_id_generator.dll — Native library for generating hardware-based device fingerprints
The HWID generator file is OS dependent; the sample uses a Windows x64 version. If you're running on another OS you need to replace this file with a corresponding version distributed with the SDK.
Other assorted required dlls
Scripts Organization
The Assets/Scripts/ folder contains the application logic:
Config.cs- SDK configuration and credentialsLicenseSpringManager.cs- SDK lifecycle and license operationsLicenseManagementUI.cs- Activation/deactivation UI controllerLicenseDetailsUI.cs- License information displayProductDetailsUI.cs- Product information displayEditor/DefaultSceneLoader.cs- Auto-loads scene on project open
5. Script Architecture
Understanding how the scripts work together:
Config.cs - Configuration and Credentials
This static class holds your LicenseSpring credentials and configuration:
ApiKey: Your LicenseSpring API key
SharedKey: Your shared secret key for encryption
ProductCode: Your product identifier
The CreateConfiguration() method:
Builds a Configuration object with your credentials
Sets up ExtendedOptions (logging, network info, file paths, etc.)
Returns a ready-to-use configuration
You'll modify this file to add your own credentials.
LicenseSpringManager.cs - SDK Lifecycle Manager
This is the core singleton manager that handles all SDK operations.
Key responsibilities:
Initializes the SDK on application startup
Provides a global access point via Instance property
Manages license activation and deactivation
Handles local license file operations
Important methods:
InitializeSdk()- Initializes SDK (called automatically)ActivateLicense(key)- Activates a license with provided keyDeactivateCurrentLicense()- Deactivates the active licenseClearLocalStorage()- Deletes local license filesGetDataLocation()- Returns license file storage pathIsInitialized- Property to check if SDK is ready
Singleton pattern: Only one instance exists throughout the application lifecycle. Access it via: LicenseSpringManager.Instance
This is not mandatory; you could also instantiate multiple managers and handle multiple licences concurrently. Just make sure you only use one manager instance per license to avoid issues.
LicenseManagementUI.cs - License Operations UI
This script controls the top portion of the UI for license operations.
UI Elements:
License key input field
Local files path display
Activate button
Deactivate button
Delete local files button
Key functionality:
Collects license key input from user
Triggers activation/deactivation operations
Updates the local file path display
Communicates with LicenseDetailsUI to refresh license info
LicenseDetailsUI.cs - License Information Display
This script displays comprehensive license information and provides additional license operations.
Displayed information:
License key and type
License status and validity
Offline activation status
Trial information
Validity period and remaining days
Grace period and maintenance period
Last check timestamp
Floating license details
Consumption tracking (for usage-based licenses)
Device variables
Interactive features:
Check License — Validates license with server
Borrow License — Borrows a floating license for offline use
Sync Consumption — Syncs usage data with server
Update Consumption — Updates local consumption value
Add Device Variable — Adds test device-specific data
ProductDetailsUI.cs - Product Information Display
This script fetches and displays product information.
Displayed information:
Product name
Product code
Trial allowed (yes/no)
Trial period duration (in days)
Authorization type (license key, user-based, etc.)
Functionality:
Loads product details from the SDK
Displays them in the UI
How They Work Together
Flow:
6. Configuration
To use the SDK with your own LicenseSpring account, you need to update the credentials in Config.cs.
Hardware ID Algorithm Options
The SDK supports multiple algorithms for generating device fingerprints. In CreateExtendedOptions() you'll see:
Available options:
HardwareIdGeneratorWindowsHardwareFingerprintId(recommended for Windows)HardwareIdGeneratorWindowsUuidHardwareIdGeneratorMacOSSerialNumberHardwareIdGeneratorMacOSPlatformUuidMultiple legacy algorithms
Choose the one that best fits your target platform(s).
Local License File Storage
The SDK stores activated licenses locally in encrypted files. The storage location is configured in ExtendedOptions:
You can customize this path to any location. On different platforms, Unity will adjust the path accordingly:
Windows:
C:\Users\[Username]\AppData\Local\LicenseSpring\unitymacOS:
~/Library/Application Support/LicenseSpring/unityLinux:
~/.local/share/LicenseSpring/unity
Note: Use Unity's Application.persistentDataPath for cross-platform compatibility:
7. Running the Sample
How to Enter Play Mode
What Happens on Initialization
When you press Play, here's what happens behind the scenes:
Unity instantiates all GameObjects in the scene
LicenseSpringManager.Awake()is called immediatelyInitializeSdk()runs, setting up the SDK with your configurationUI scripts wait for initialization to complete
ProductDetailsUI loads and displays product information
The UI becomes interactive and ready for license operations
You'll see log messages in the Unity Console window showing the initialization progress.
UI Walkthrough
The sample UI is organized into several sections:
PRODUCT DETAILS
Product Name
Product Code
Trial Allowed
Trial Period
Authorization Type
LICENSE MANAGEMENT
License Key Input Field
[Activate] [Deactivate] buttons
Local Files Path Display
[Delete Local Files] button
LICENSE DETAILS
License Key
License Type
License Status
Offline Activation Status
Validity Period
Days Remaining
Last Checked
Is Trial
Floating License Info
[Check License] [Borrow License] buttons
CONSUMPTION TRACKING (for usage-based licenses)
Total Consumption
Max Consumption
[Sync Consumption] [Update Consumption] buttons
DEVICE VARIABLES
Display of device-specific key-value pairs
[Add Device Variable] button
To stop the sample: Click the Stop button to exit Play mode.
8. Testing Scenarios
This section provides step-by-step walkthroughs for testing different licensing scenarios.
SCENARIO 1: Basic Online Activation
This is the most common scenario — activating a license with internet access.
Click Play in Unity Editor to run the sample
Wait for the SDK to initialize (you'll see product details populate)
In the "License Key" input field, enter your test license key (You should have received this from your LicenseSpring account)
Click the [Activate] button
If successful, you'll see:
License details populate with information
License status shows "Active"
Validity period and expiration date display
Days remaining shows the time left on the license
Check the Unity Console for detailed log messages
What to Observe:
The license file is saved locally (path shown in "Local Files Path")
The activated license persists between Play mode sessions
Product features and restrictions are now enforced
SCENARIO 2: License Checking and Validation
After activating a license, you can validate it with the server.
Ensure you have an activated license (see Scenario 1)
Click the [Check License] button in the License Details section
The SDK will contact the LicenseSpring server to validate:
License is still active
License hasn't been revoked
Device is still authorized
Any policy changes from the server
If valid, the license details refresh with updated information
The "Last Checked" timestamp updates to the current time
What This Does:
Validates that the license is still active server-side
Ensures the license hasn't been transferred to another device or disabled
Syncs any server-side changes
Updates local license data with latest server information
When to Use:
Periodically during application runtime (e.g., daily)
When up to date server information is needed (e.g., floating licensing)
Before enabling premium features
After significant time offline
SCENARIO 3: License Deactivation
Deactivating a license frees up an activation slot and removes local data.
Ensure you have an activated license (see Scenario 1)
Click the [Deactivate] button in the License Management section
The SDK will:
Contact the server to release the activation
Delete the local license file
Clear all license information from the UI
The activation slot is now available for another device
All license details fields will become empty
Click the [Delete local files] button
What to Observe:
The local license file is deleted (verify by checking the file path)
The device is no longer counted against the max activations
You can activate a different license key now
Use Cases:
Transferring license to another device
Testing different license configurations
End of license period
Application uninstallation
SCENARIO 4: Floating License Borrowing/Release
Floating licenses allow temporary offline usage by "borrowing" a license.
Prerequisites:
Your license must be a floating license type
The license must have borrowing enabled
What This Enables:
Temporary offline usage
Predetermined borrow period (configured in your LicenseSpring account)
Ensures license returns to pool when no longer needed
Floating License Timeout: If you don't interact with the application, the floating license will automatically timeout and return to the pool.
SCENARIO 5: Consumption Tracking
For usage-based licensing (e.g., API calls, credits, processing time).
Prerequisites:
Your license must be configured for consumption tracking
The license must have a max consumption value set
Steps to Update Consumption
Activate a license with consumption tracking enabled
In the Consumption section, note the "Total Consumption" and "Max Consumption"
Click [Update Consumption] button
The local consumption value increments (simulating usage)
The "Total Consumption" field updates to reflect the new value
What to Observe:
Consumption persists locally until synced
The SDK can operate offline and sync later
Server-side reporting shows usage analytics
Use Cases:
API call credits
Processing time tracking
Feature usage limits
Pay-per-use models
SCENARIO 6: Device Variables
Device variables are custom key-value pairs stored with the license on the device.
Activate a license (see Scenario 1)
Click [Add Device Variable] button
A test device variable is added
The device variable appears in the Device Variables display section
Device variables persist locally with the license file
What This Enables:
Store device-specific configuration
Track custom data per installation
Implement feature flags per device
Debug and support purposes
SCENARIO 7: Working with Local License Files
Understanding how local license storage works.
What to Observe:
License files are encrypted
Files persist between Play mode sessions
Deleting files doesn't deactivate server-side (the activation slot remains used)
To properly deactivate, always use the [Deactivate] button first
9. Customization Guide
How to Integrate the SDK into Your Own Unity Project
This section explains how to take the LicenseSpring SDK and integrate it into your own Unity application.
Step 1: Copy the DLLs Folder
In your UnitySample project, locate:
Copy the entire LicenseSpring folder
In your own Unity project, paste it into:
Unity automatically recognizes DLLs in the Plugins folder. Just drag and drop them in the folder and wait for Unity to initialize the files.
It's possible you will need additional dlls not included with this demo, or that not all DLLs are needed; this depends on your specific SDK usage.
Step 2: Create Your Own Configuration
Create a new C# script in your project (e.g., MyLicenseConfig.cs) and add your LicenseSpring credentials:
Customize ExtendedOptions as needed (logging, file paths, etc.)
Step 3: Initialize the SDK
Create a manager script that initializes the SDK when your application starts:
Attach this script to a GameObject in your scene (e.g., a "LicenseManager" empty GameObject).
Step 4: Implement License Checking in Your Application Flow
Decide where in your application you want to check the license:
On application startup (in Awake or Start)
Before enabling premium features
Periodically during runtime
Before critical operations
Example: Check license before starting the main application:
Step 5: Persistence Considerations
The SDK automatically handles license persistence through local files. However, consider:
Where to store license files (use
Application.persistentDataPath)How often to check with the server (balance security vs. performance)
Grace period configuration (allow temporary offline usage)
How to handle license expiration gracefully in your UX
Example of configuring file path:
Best Practices
Initialize Early
Initialize the SDK as early as possible in your application lifecycle
Use
Awake()or a[RuntimeInitializeOnLoadMethod]for earliest execution
Handle Exceptions Gracefully
Wrap SDK calls in try-catch blocks
Provide user-friendly error messages
Log detailed errors for troubleshooting
Check Licenses Periodically
Don't just check once at startup
Periodically validate with the server
Respect Offline Grace Periods
Allow users to work offline within configured grace periods
Only enforce strict checks when online
Provide clear messaging when license checks fail
Test Different Scenarios
Test online activation
Test offline behavior
Test license expiration
Test max activations reached
Test invalid license keys
Provide Clear User Feedback
Display clear error messages
Explain why activation failed
Provide support contact information
Build Platform Considerations
Test on each target platform (Windows, macOS, Linux, Android, iOS)
Verify file paths work cross-platform
Ensure hardware ID generation works on all platforms
Test IL2CPP builds (not just Mono)
10. Additional Information
SDK Documentation
The LicenseSpring.xml file in Assets/Plugins/LicenseSpring/ contains complete API documentation. This enables IntelliSense in Visual Studio and Rider.
To view API docs:
Open your C# script in Visual Studio
Type
LicenseSpring.and IntelliSense will show available classesHover over methods to see parameter descriptions and return types
Main SDK Documentation
For comprehensive documentation, visit:
https://docs.licensespring.com/
Topics covered:
SDK installation and setup
Advanced features (SSO, consumption, floating licenses)
Best practices
API reference
Platform-specific guides
Support
If you need assistance:
Check the documentation at: https://docs.licensespring.com/
Contact LicenseSpring Support:
https://licensespring.zendesk.com/hc/en-us/requests/new
Include:
Unity version
Error messages from Console
Platform (Windows, macOS, etc.)
Steps to reproduce the issue
Please be as detailed as possible.
Sample Project Updates
The UnitySample project is maintained as part of the LicenseSpring .NET SDK repository. Check for updates periodically to get:
Bug fixes
New feature demonstrations
Performance improvements
Unity version updates
Final Notes
Congratulations! You now have a comprehensive understanding of the LicenseSpring Unity SDK and the UnitySample project.
The LicenseSpring SDK provides powerful and flexible licensing for Unity applications. Take advantage of its features to protect your software and provide a great experience for your users.
Happy licensing! 🎉
Was this helpful?