M8 CMS SDK for Unity
A powerful Unity SDK for integrating with the M8 CMS (GameFlow CMS) backend, enabling real-time content management and delivery for mobile games.
๐ Documentation
| Document | Description |
|---|---|
| Quick Start Guide | Get up and running in 5 minutes |
| Complete Documentation | Full API reference and features |
| API Quick Reference | Cheat sheet for common operations |
๐ Quick Start
-
Add to Scene
ShellAdd M8CMS_SDK_Prefab to your scene -
Access the SDK
C#using M8CMS; var cmsManager = M8CMSManager.Instance; -
Get Your Content
C#// Listen for data loaded event M8CMSManager.OnGameDataLoaded += (GameData data) => { Debug.Log($"Loaded {data.levels.Count} levels!"); }; // Load level image var sprite = await cmsManager.GetLevelSpriteAsync(levelIndex); myImage.sprite = sprite;
That's it! Your content is now live from Firebase.
โจ Key Features
- ๐ Automatic Content Management - Intelligent downloading based on player progress
- ๐๏ธ Version Management - Support for multiple content versions (Live, Latest, Specific)
- ๐พ Smart Caching - Three-level cache system (in-memory, file system, preload)
- ๐ฑ Cross-Platform - Supports Android, iOS, and Web
- โก Event-Driven - Subscribe to events for reactive updates
- ๐จ Built-in Content - Optional offline fallback content
- ๐ Progress Tracking - Track player consumption for intelligent pre-downloading
๐ What You Get
Levels & Collections
C#// Get level data Level level = cmsManager.GetLevelByIndex(5); // Load images and videos var image = await cmsManager.GetLevelSpriteAsync(levelIndex); var video = await cmsManager.GetLevelVideoAsync(levelIndex);
Automatic Downloads
C#// When player reaches a level cmsManager.ConsumeLevelContent(levelIndex); // SDK automatically downloads: // - Current level content // - N levels ahead (configurable)
Version Management
C#// Switch content versions cmsManager.SetVersionSelectionMode(VersionSelectionMode.Specific); cmsManager.SetSelectedVersionName("v1.2.0"); // Get available versions var versions = await cmsManager.GetAllVersionsAsync();
๐ Requirements
- Unity 2021.3 or higher
- Firebase Unity SDK (included)
- Internet connection for Firebase (optional with built-in content)
๐ฏ Use Cases
Level-Based Games
C#void StartLevel(int levelIndex) { // Track player progress cmsManager.ConsumeLevelContent(levelIndex); // Get level configuration Level level = cmsManager.GetLevelByIndex(levelIndex); SetupGrid(level.gridSize); SetReward(level.rewardCoin); }
Collection Galleries
C#void DisplayCollection() { var collections = cmsManager.GetAllCollections(); foreach (var item in collections) { LoadGalleryItem(item); } }
Content Previews
C#async void ShowPreview(int levelIndex) { var sprite = await cmsManager.GetLevelSpriteAsync(levelIndex); previewImage.sprite = sprite; }
๐ ๏ธ Configuration
Configure the SDK in Unity Inspector:
| Setting | Description |
|---|---|
appKey | Your game's unique identifier |
downloadImagesVideosOnStart | Items to download immediately |
downloadNewLevelsBeforeXLevel | Levels to pre-download ahead |
maxCacheSize | Maximum cache size (MB) |
enableBuiltInContent | Use offline content |
๐ Project Structure
Assets/
โโโ Scripts/M8CMS/
โ โโโ M8CMSManager.cs # Main SDK manager
โ โโโ Examples/ # Example implementations
โ โโโ Services/ # Firebase services
โ โโโ Helpers/ # Utility helpers
โ โโโ Models/ # Data models
โโโ M8CMS_SDK_Prefab.prefab # Preconfigured prefab
โโโ Resources/ # Built-in content (optional)
๐ Example Scenes
Check out the example scenes in Assets/Scripts/M8CMS/Examples/:
M8CMSExample.cs- Basic usage and UIM8CMSVersionManagerExample.cs- Version management
๐ง API Overview
Initialization
C#// SDK auto-initializes M8CMSManager.OnInitializationComplete += (bool success) => { // Ready to use };
Loading Content
C#// Async methods var sprite = await cmsManager.GetLevelSpriteAsync(index); var video = await cmsManager.GetLevelVideoAsync(index);
Events
C#// Subscribe to events M8CMSManager.OnGameDataLoaded += OnDataLoaded; cmsManager.OnLevelContentReady += OnLevelReady;
๐ Troubleshooting
SDK not initializing?
- Check internet connection
- Verify
appKeyis correct - Enable debug logs
Content not loading?
- Check Firebase URLs
- Verify cache size limits
- Check content availability
See Documentation for more solutions.
๐ Support
- ๐ Complete Documentation
- โก Quick Start Guide
- ๐ API Reference
- ๐ฌ Contact M8 CMS support team
๐ License
This SDK is part of the M8 CMS ecosystem. Use in accordance with your agreement with M8 CMS.
Made with โค๏ธ for Unity Developers