CrateBytes Unity SDK
A comprehensive Unity SDK for integrating CrateBytes backend services into your games. This SDK provides authentication, session management, leaderboards, and player metadata functionality.Installation
There are two ways to install the CrateBytes Unity SDK:Method 1: Unity Package Manager (Recommended)
- Open Unity Package Manager (
Window > Package Manager
) - Click the + button in the top-left corner
- Select “Add package from git URL”
- Enter the repository URL:
https://github.com/CrateBytes/CrateBytes-UnitySDK.git
- Click Add
Method 2: Manual Installation
- Visit the CrateBytes Unity SDK GitHub repository
- Download the latest release or clone the repository
- Import the package into your Unity project
Setup After Installation
- Add the
CrateBytesSDK
component to a GameObject in your scene - Configure the SDK with your project’s base URL and public key
Configuration
SDK Settings
The SDK can be configured through the Inspector or via code:Logging
The SDK includes a built-in logging system that can be enabled/disabled: Via Inspector:- Select the GameObject with the
CrateBytesSDK
component - Check/uncheck the “Enable Logging” field
Quick Start
1. Setup
Add the SDK component to your scene:2. Authentication
3. Session Management
4. Leaderboards
5. Player Metadata
Best Practices
1. Session Management
- Always start a session when the player begins playing
- Use automatic heartbeat to keep sessions alive
- Stop sessions when the player stops playing or the app is paused
2. Error Handling
- Always check response success before using data
- Implement retry logic for network failures
- Log errors for debugging
3. Data Management
- Use strongly-typed data structures for player metadata
- Validate data before sending to the server
- Handle data serialization errors gracefully
4. Performance
- Use coroutines for all API calls
- Don’t make too many requests simultaneously
- Cache frequently accessed data locally