Readme

General project information.

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

DocumentDescription
Quick Start GuideGet up and running in 5 minutes
Complete DocumentationFull API reference and features
API Quick ReferenceCheat sheet for common operations

๐Ÿš€ Quick Start

  1. Add to Scene

    Shell
    Add M8CMS_SDK_Prefab to your scene
  2. Access the SDK

    C#
    using M8CMS;
    
    var cmsManager = M8CMSManager.Instance;
  3. 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:

SettingDescription
appKeyYour game's unique identifier
downloadImagesVideosOnStartItems to download immediately
downloadNewLevelsBeforeXLevelLevels to pre-download ahead
maxCacheSizeMaximum cache size (MB)
enableBuiltInContentUse 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 UI
  • M8CMSVersionManagerExample.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 appKey is correct
  • Enable debug logs

Content not loading?

  • Check Firebase URLs
  • Verify cache size limits
  • Check content availability

See Documentation for more solutions.

๐Ÿ“ž Support

๐Ÿ“„ License

This SDK is part of the M8 CMS ecosystem. Use in accordance with your agreement with M8 CMS.


Made with โค๏ธ for Unity Developers