Unity SDK

Complete guide for integrating StatPotion with Unity games

Last updated: 12/20/2024

Requirements
Unity Version

Unity 2020.3 LTS or newer

.NET Version

.NET Standard 2.1 support

Basic Setup

Initialize StatPotion in your Unity project

Installation: Download StatPotionSDK.cs and place it in your Assets/Scripts folder.

Save & Load Player Data

Store player progress with serializable classes

Live Configuration

Load dynamic game settings

Event Tracking

Track player behavior in your Unity game

Complete Integration Example

Production-ready GameManager with all features

Platform Considerations
🎮 Mobile (iOS/Android)

Auto-save on application pause/focus lost events for seamless mobile experience.

OnApplicationPause()
🖥️ Desktop

Save on significant progress milestones and application quit.

OnApplicationQuit()
🌐 WebGL

Consider more frequent auto-saves as users may close browser tabs unexpectedly.

Auto-save
Unity Best Practices
🔄 Async/Await

Use async methods for all StatPotion calls. Avoid blocking the main thread.

📱 Network State

Check Application.internetReachability before making requests on mobile.

🚨 Error Handling

Wrap all StatPotion calls in try-catch blocks and provide fallback behavior.