Skip to main content

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:
  1. Open Unity Package Manager (Window > Package Manager)
  2. Click the + button in the top-left corner
  3. Select “Add package from git URL”
  4. Enter the repository URL: https://github.com/CrateBytes/CrateBytes-UnitySDK.git
  5. Click Add

Method 2: Manual Installation

  1. Visit the CrateBytes Unity SDK GitHub repository
  2. Download the latest release or clone the repository
  3. Import the package into your Unity project

Setup After Installation

  1. Add the CrateBytesSDK component to a GameObject in your scene
  2. 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
Via Code:
Note: Logging is disabled by default for production builds. Enable only when debugging.

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