Unity Integration Examples
Complete C# examples for Unity with HTTP client and JSON handling
Friends chat
Download IDCChatManager.cs for friends chat REST + Reverb. IDCMatchVoiceManager.cs / IDCMatchVoiceLiveKitBridge.cs for match sessions, VAD policy, and LiveKit credentials (see Match Voice).
Chat API & Unity real-time guideAvailable Examples
Download and integrate these C# scripts into your Unity project to quickly get started with the IDCGames API.
IDCChatManager
6.1 KBFriends direct-message chat: REST against /api/v1/chat.
LoginResponse
28.8 KBMain API manager for IDCGames integration in Unity
IDCGamesGamingPanelExample
11.4 KBExample implementation showing how to use IDCGamesAPIManager
IDCMatchVoiceLiveKitBridge
1.7 KBHook LiveKit Unity SDK here after JoinMatchAsync returns voice.url + voice.token.
IDCMatchVoiceManager
7.8 KBMatch session: group chat + voice (LiveKit or Mumble) via /api/v1/matches.
IDCMatchVoiceProductionSmokeTest
5.7 KBMinimal production smoke test for match voice (LiveKit token from panel).
Prerequisites
Unity Requirements
- • Unity Version: 2020.3 LTS or newer
- • Platform: Windows, macOS, or Linux
- • Scripting Backend: IL2CPP or Mono
Required Packages
Install the following package from Unity Package Manager:
Newtonsoft.Json
Required for JSON serialization/deserialization
Installation steps:
- Open Unity Package Manager (Window → Package Manager)
- Click the "+" button in the top-left corner
- Select "Add package by name..."
- Enter:
com.unity.nuget.newtonsoft-json - Click "Add" to install
Alternative: Manual Installation
If Package Manager doesn't work, add to your manifest.json:
{
"dependencies": {
"com.unity.nuget.newtonsoft-json": "3.2.1"
}
}
API Configuration
Before using the API, configure these values in the inspector:
- • Base URL: https://gamepanel.idcgames.com/api/v1
- • Game Secret: Your game's secret token
- • Game ID: Your game's unique identifier
Integration Guide
Install Prerequisites
Make sure you have installed Newtonsoft.Json package (see Prerequisites above)
Package Name: com.unity.nuget.newtonsoft-jsonVersion: 3.2.1 or newer
Download Scripts
Download the C# scripts from the examples above
IDCGamesAPIManager.cs - Main API manager scriptIDCGamesGamingPanelExample.cs - Example implementation with UI
Add to Unity Project
Place the scripts in your Unity project's Scripts folder
Assets/Scripts/IDCGames/Create the folder structure if it doesn't exist
Configure API Settings
Set up the API configuration in the inspector
Base URL: https://gamepanel.idcgames.com/api/v1Game Secret: Your game's secret tokenGame ID: Your game's unique identifier
Start Using the API
Use the API manager in your scripts
var api = IDCGamesAPIManager.Instance;
// Simple sandbox login (default parameters)
api.Login();
// Or with custom parameters
api.Login("sandbox", null, null, "MyPlayer", "player@example.com");
api.OnLoginComplete += (success) => {
if (success) {
api.GetUserStats();
}
};
Code Examples
Authentication
// Login using third-party authentication
public void Login()
{
var api = IDCGamesAPIManager.Instance;
api.OnLoginComplete += (success) => {
if (success) {
Debug.Log("Login successful!");
// Tokens are automatically saved
}
};
// Example 1: Simple sandbox login (default parameters)
api.Login();
// Example 2: Sandbox with custom username
api.Login("sandbox", null, null, "MyCustomPlayer");
// Example 3: Real platform login (Steam)
api.Login("steam", "steam_token_123", "steam_user_456", "SteamPlayer", "player@example.com");
// Example 4: IDC platform with full customization
api.Login("idc", "idc_token_789", "idc_user_101", "IDCPlayer", "player@idc.com", "US", "en");
}
// Refresh token when needed
public void RefreshToken()
{
var api = IDCGamesAPIManager.Instance;
api.RefreshToken();
}
Shop Integration
// Get shop items
public void GetShopItems()
{
var api = IDCGamesAPIManager.Instance;
api.GetShopItems((items) => {
foreach (var item in items) {
Debug.Log($"Item: {item.Name} - Price: {item.Price}");
}
});
}
// Buy shop item
public void BuyItem(int itemId, int quantity = 1)
{
var api = IDCGamesAPIManager.Instance;
api.BuyShopItem(itemId, quantity, (success) => {
if (success) {
Debug.Log("Item purchased successfully!");
}
});
}
Stats Submission
// Submit game statistics
public void SubmitGameStats()
{
var api = IDCGamesAPIManager.Instance;
var sessionStats = new Dictionary {
{"kills", 5},
{"deaths", 2},
{"assists", 3},
{"wins", 1},
{"score", 1500}
};
var eventProgress = new Dictionary {
{"event_1", 10},
{"event_2", 5}
};
api.SubmitGameStats(sessionStats, eventProgress, (success) => {
if (success) {
Debug.Log("Stats submitted successfully!");
}
});
}
Inventory Management
// Get player inventory
public void GetInventory()
{
var api = IDCGamesAPIManager.Instance;
api.GetInventory((inventoryResponse) => {
if (inventoryResponse.success) {
Debug.Log($"Total items: {inventoryResponse.stats.total_items}");
Debug.Log($"Unique items: {inventoryResponse.stats.unique_items}");
// Display category statistics
foreach (var category in inventoryResponse.category_stats) {
Debug.Log($"{category.Key}: {category.Value.count} items");
}
// Display inventory items
foreach (var item in inventoryResponse.inventory) {
Debug.Log($"Item: {item.shop_object.name}");
Debug.Log($"Quantity: {item.quantity}");
Debug.Log($"Status: {item.attributes.status}");
Debug.Log($"Purchased: {item.attributes.purchased_at}");
// Display item properties
if (item.shop_object.content != null) {
foreach (var prop in item.shop_object.content) {
Debug.Log($"{prop.Key}: {prop.Value}");
}
}
}
}
});
}
// Example JSON Response Structure:
/*
{
"success": true,
"inventory": [
{
"shop_object": {
"id": 19,
"name": "AK-47",
"soft_coin_cost": 2700,
"currency_type": "gold",
"content": {
"damage": "36",
"accuracy": "73",
"rarity": "epic"
}
},
"quantity": 1,
"attributes": {
"shop_item_price_id": 1,
"status": "active",
"purchased_at": "2025-09-25 11:25:21",
"purchase_price": 0
}
}
],
"category_stats": {
"Principal": {"count": 1, "total_quantity": 1}
},
"stats": {
"total_items": 1,
"unique_items": 1,
"total_value": 0
}
}
*/
Features
Core Features
- • Singleton Pattern: Easy access from anywhere
- • Event System: Subscribe to API events
- • Auto Token Management: Automatic refresh
- • Error Handling: Comprehensive error management
- • JSON Parsing: Automatic response parsing
API Support
- • Authentication: Login, refresh, validate
- • Shop System: Browse, buy items
- • Inventory System: Get inventory with detailed stats
- • Stats System: Submit and retrieve
- • Rewards System: Daily rewards
- • User Management: Profile updates