Skip to main content

Getting started

Overview​

CurseForge for Studios gives your Unity game a mod ecosystem you do not have to build or host. Players browse, install and update mods from inside your game. CurseForge runs the storefront, the content delivery, the moderation queue and the ownership records behind it.

This page is the whole integration in order, from the first decision to the moment a mod loads in your game. It is a map rather than a manual. Each step states what it involves and links to the page that covers it in full.

The work splits into two halves, and the first one is easy to underestimate. The first half is your own game: it has to be able to load third-party content at all, and you decide where that content sits on disk and at which moment your game reads it. No SDK can make those decisions for you. The second half is the SDK, which finds mods, downloads them, keeps them current, and tells your game which ones are ready to load.

Browsing and installing mods is the smallest useful milestone. Selling mods, following a player's mod list across their devices, keeping a multiplayer session on one mod set, and letting players publish their own content are separate layers you add afterwards, in any order you like.

Some capabilities are switched on per game by CurseForge rather than in your project. Plan a short conversation with us before you build against those.

Before you write any code​

Three things need to be true before the SDK is any use to you.

PrerequisiteWhy it matters
Your game can load modsThe SDK puts content on disk and tells you what is there. It does not make your game read it. Whatever form your mods take, your game needs the code to load them
Your game is registeredA game record gives you the game id and API key that scope every call. See Setting up your game
Gated capabilities are set up for your gamePremium mods and some sign-in providers need setup on CurseForge's side for your game, beyond any setting in your project. Email cfforstudios@overwolf.com

Two decisions are also yours, and both are easier to make now than to change later.

Where mods live on disk. Pick the directory, and pick the layout inside it. See Deciding how mods sit on disk below.

When your game loads them. Reading mods off disk at an arbitrary moment tends to break things. Pick a point where your game is already loading content: when the player starts play from the main menu, when a new scene loads, or immediately before a match begins.

The integration path​

Nine steps, in order. Steps 1 and 2 happen outside your Unity project.

StepWhat it involvesCovered in
1. Add mod support to your gameYour own loading code for whatever your mods containYour codebase
2. Register your gameCreate the game record, collect the game id and API keySetting up your game
3. Import the packagesThe Unity integration, plus the UI package if you want the prebuilt browserInstallation
4. Configure the settingsGame id, API key, mods directory and user data directory at minimumInitialization and settings
5. Initialize the SDKBring it up once at startupInitialization and settings
6. Sign the player inOnly needed for some capabilities. See the step belowAuthentication
7. Let players find modsQuery the catalogue yourself, or ship the prebuilt browserBrowsing and discovery, Mod browser
8. Install a modStart an install, track progress, handle failureInstalling mods
9. Load installed modsAsk the SDK what is installed, decide what is loadable, load itInstalling mods
tip

Read Error handling alongside step 5 rather than after step 9. Failures arrive through two different error types depending on the area, and picking that up late means rewriting call sites.

The samples below use the core API. If you ship the prebuilt browser, each step ends with a Prebuilt UI line naming the CFUnity member that does the same thing. Pick one entry point for your game: see The two entry points.

1. Add mod support to your game​

This is the part that is not about CurseForge. Your game needs to accept content it did not ship with, whether that is scripts, asset bundles, or configuration. If your game cannot do that yet, the SDK has nothing to hand it.

2. Register your game​

Create your game in the Developer Portal at console.curseforge.com. You get a game id and an API key, which together scope every call the SDK makes. This is also where you set up categories, classes and permitted platforms, and where per-game capabilities get switched on.

3. Import the packages​

Import the Unity integration package into your project. If you want the prebuilt mod browser, import the UI package as well. The UI package builds on the Unity integration, so the integration is always required.

The script that calls BootstrapUnity.Create, as the step 5 sample does, must sit in an assembly definition that references CFCore.Unity, because that assembly is not auto-referenced. Scripts that only use ICFCore, the core models, CFUnity or the prebuilt browser need no extra reference.

Get the SDK on GitHub.

Importing the packages does not start the SDK. Nothing happens until you initialize it.

4. Configure the settings​

There are two ways to supply settings.

ApproachWhere the values liveUse it when
A Settings objectYour own codeYou call the core API directly
The CurseForgeSettings assetProject Settings > CurseForge Settings, saved as an asset in your projectYou use the prebuilt browser or CFUnity

Four values matter from the start: the game id and API key from step 2, the mods directory where installed mods go, and the user data directory where the SDK keeps the player's session and library state.

The settings asset builds the two directories for you. It places a mods folder and a user_data folder under one storage location: by default, Unity's persistent data path in a build, and a cfcore folder in your project directory while you work in the editor. Both locations are settings on the asset.

5. Initialize the SDK​

Bring the SDK up once, early, and wait for the callback before calling anything else. Until initialization succeeds, every area member of ICFCore is null. Make every call from Unity's main thread. Success and failure callbacks come back on the main thread too. Install progress reported while a mod unzips is the exception: it arrives on a background thread. See Threading and callbacks.

using Overwolf.CFCore.Base;
using Overwolf.CFCore.Base.Models;
using Overwolf.CFCore.Unity;
using UnityEngine;

public class CurseForgeStartup : MonoBehaviour {
[SerializeField] private uint _gameId;
[SerializeField] private string _apiKey;

public ICFCore Core { get; private set; }

private void Start() {
string root = Application.persistentDataPath;

Settings settings = new Settings {
GameId = _gameId,
ApiKey = _apiKey,
ModsDirectory = System.IO.Path.Combine(root, "mods"),
UserDataDirectory = System.IO.Path.Combine(root, "user_data")
};

Core = BootstrapUnity.Create(settings);
Core.Initialize(
new InitializationOptions { UserContextId = "local" },
() => Debug.Log("CurseForge ready"),
(string error) => Debug.LogError($"CurseForge init failed: {error}"));
}
}

Prebuilt UI: call Initialize on the CurseForgeUI component of the browser prefab. It reads the CurseForgeSettings asset and initializes CFUnity for you. Full reference on Initialization and settings.

6. Sign the player in​

Plenty of a mod integration works without a signed-in player. Browsing the catalogue and installing free mods do not need one. Authentication is required for anything tied to a person: subscriptions that follow them across devices, rating, reporting, buying premium mods, and publishing their own content.

The SDK supports sign-in through the player's platform identity on Steam, PlayStation Network, Xbox Live, GOG Galaxy and Epic Games, and an email one-time code flow elsewhere. Each provider is enabled and configured per game in the Developer Portal. Show the player the current terms before signing them in, and pass the time they accepted them.

using System;
using Overwolf.CFCore.Base;
using Overwolf.CFCore.Base.Api.Models;
using Overwolf.CFCore.Base.Api.Models.Enums;
using Overwolf.CFCore.Base.Common;
using UnityEngine;

public class CurseForgeSignIn : MonoBehaviour {
public void SignInWithSteam(ICFCore core,
string steamSessionTicket,
DateTime termsAcceptedAtUtc) {
AuthExternalAdditionalInfo info = new AuthExternalAdditionalInfo {
EulaAcceptTime = termsAcceptedAtUtc
};

core.Authentication.GenerateAuthTokenByExternalProvider(
AuthExternalProviders.Steam,
steamSessionTicket, // base64 of the Steam session ticket
info,
() => Debug.Log("Signed in"),
(CFCoreError error) => Debug.LogError(error.Description));
}
}

For the email path, call SendSecurityCode with the player's address, then GenerateAuthToken with the code they received.

Prebuilt UI: pass a function that returns the provider and token to CurseForgeUI.Initialize. The browser shows the terms prompt and signs the player in with CFUnity.TryAuthenticateWithToken. Full flow on Authentication.

7. Let players find mods​

Two options, and they are not exclusive. Query the catalogue yourself and build your own interface, which gives you full control of the presentation. Or add the UI package, a prebuilt in-game browser that already covers discovery, search, mod pages, ratings, sign-in and subscriptions, and opens the player's web browser for reporting and checkout.

using System.Collections.Generic;
using Overwolf.CFCore.Base;
using Overwolf.CFCore.Base.Api.Common;
using Overwolf.CFCore.Base.Api.Models;
using Overwolf.CFCore.Base.Api.Models.Filters;
using UnityEngine;

public class ModSearch : MonoBehaviour {
public void RunSearch(ICFCore core, string text) {
SearchModsFilter filter = new SearchModsFilter { SearchFilter = text };
ApiRequestPagination page = new ApiRequestPagination {
Index = 0, // zero based index of the first result
PageSize = 20 // 20 is also the default
};

core.Api.SearchMods(
filter,
page,
(ApiResponseWithPagination<List<Mod>> response) => {
foreach (Mod mod in response.Data) {
Debug.Log($"{mod.Id}: {mod.Name}");
}
},
(ApiResponseError error) => Debug.LogError(error.Description));
}
}

Prebuilt UI: CFUnity.Catalog.SearchAndDownloadMods. Full filter reference on Browsing and discovery.

8. Install a mod​

Hand the SDK a mod and it downloads, verifies and extracts it, reporting progress as it goes. Without a specific file, it installs the mod's main file. Installs are cancellable, and updates run through the same path.

using Overwolf.CFCore.Base;
using Overwolf.CFCore.Base.Api.Models;
using Overwolf.CFCore.Base.Common;
using Overwolf.CFCore.Base.Library.Models;
using UnityEngine;

public class ModInstaller : MonoBehaviour {
public void InstallLatest(ICFCore core, Mod mod) {
core.Library.Install(
mod,
(InstalledMod installed) => Debug.Log($"Installed {mod.Name}"),
(LibraryProgress progress) => {
// 0 to 100 within each stage. progress.State names the stage.
uint percent = progress.DataTransfer?.Progress ?? 0;
},
(CFCoreError error, InstalledMod installed) =>
Debug.LogError(error.Description));
}
}

Prebuilt UI: CFUnity.Install.InstallMod, with RegisterInstallListener for state and progress. Full reference on Installing mods.

9. Load installed mods​

Earlier you chose the point where your game reads mods from disk. At that point, ask the SDK what is installed. Each installed mod carries what you need to decide whether to touch it. Load a mod only when its Status is Normal (up to date) or OutOfDate (installed, with a newer file available). Skip everything else: Pending means the download has not finished, and Invalid means its files were deleted or modified on disk.

FieldWhat to do with it
StatusLoad only the two statuses above
EnabledThe player can turn a mod off without uninstalling it. Respect it
PathOnDiskWhere the mod's files are. With the default layout it is relative to your mods directory

GetInstalledMods returns every installed mod for the current player, including ones still installing, which is exactly why you check Status rather than assuming.

using System.Collections.Generic;
using Overwolf.CFCore.Base;
using Overwolf.CFCore.Base.Common;
using Overwolf.CFCore.Base.Library.Models;
using Overwolf.CFCore.Base.Library.Models.Enums;
using UnityEngine;

public class ModLoader : MonoBehaviour {
public void LoadEnabledMods(ICFCore core, string modsDirectory) {
core.Library.GetInstalledMods(
(List<InstalledMod> mods) => {
foreach (InstalledMod mod in mods) {
if (!mod.Enabled) { continue; }
if (mod.Status != InstalledModStatus.Normal &&
mod.Status != InstalledModStatus.OutOfDate) {
continue;
}

string path =
System.IO.Path.Combine(modsDirectory, mod.PathOnDisk);
// Load the mod's content from |path|.
}
},
(CFCoreError error) => Debug.LogError(error.Description));
}
}

Prebuilt UI: CFUnity.Install.GetInstalledMods, or its cached InstalledMods list, which is refreshed by GetInstalledMods, installs and uninstalls. Full status reference on Installing mods.

Deciding how mods sit on disk​

ModsDirectoryMode picks the layout inside your mods directory.

ModeLayoutUse it when
CFCoreStructureA folder named after your game id, then a folder per mod and file, named <mod id>_<file id>. The defaultAlmost always. The SDK owns the tree and can tell file revisions apart
CFCoreStructureWithoutGameIdA folder per mod and file directly in the mods directory, with no game id folderThe mods directory already belongs to this one game
FlatMod contents sit directly in the mods directoryYour game requires a specific flat layout, or players create local drafts of their own mods
warning

Creating and renaming local drafts only works in Flat mode. In any other mode those calls throw a NotSupportedModsDirModeException. If your game will let players build mods as local drafts before publishing, choose Flat from the start. See Creating UGC.

note

With Flat, PathOnDisk is the absolute path of the file's first module only. The sample in step 9 still finds it, but a mod with several modules needs adapting. How to read it in each mode is on Installing mods.

warning

In the two structured modes, the SDK deletes every folder in the mods directory that is not an installed mod, each time it starts. Keep nothing else in that directory. Switching from CFCoreStructure to CFCoreStructureWithoutGameId therefore deletes the old game id folder, with every installed mod in it, at the next startup. The SDK never moves mods between layouts, so settle the mode before players have mods installed.

Before you ship​

Three things are worth doing before a build reaches players.

Turn on the file logger. The SDK is silent by default. Set the logger output to write rolling log files, which land in a logs folder inside the user data directory, with a size cap and a retained history count. When a player cannot install a mod, these logs are what makes the problem diagnosable. See Error handling.

Decide your analytics categories. Both categories are off by default. Once you enable performance and stability analytics, the SDK reports install outcomes for you, covering success rates across your mod ecosystem. User engagement analytics cover what you report through three calls from your own code, plus the browsing events the prebuilt browser sends for you. See Analytics.

Check every call site for initialization. Area members are null until initialization succeeds, and a call through one throws in your code rather than reaching a failure callback. Make sure your game still behaves when the initialization callback reports a failure.

What you add next​

Each of these is independent. Add them in whatever order matches your roadmap.

CapabilityWhat it addsPage
Mod dependenciesHandling mods that require, prefer or conflict with other mods. The SDK reports the relationships and your game decides what to doMod dependencies
SubscriptionsA player's mod list follows them to any device running your gameSubscriptions
Multiplayer and serversEvery participant in a session ends up on the same mod setMultiplayer and servers
MonetizationSelling individual mods, through browser checkout or a console store, with time-limited trialsMonetization
Creating UGCPlayers publish and update their own mods from your gameCreating UGC
Ratings and reportingWhat a signed-in player does to a mod besides installing itRatings and reporting

For the shape of the SDK itself, the parts and the two entry points, read Overview. For a per-page summary of everything in this section, read In this section.

Getting help​

For integration questions, SDK access, or to have a capability enabled for your game, contact cfforstudios@overwolf.com. Game and content configuration is in the Developer Portal at console.curseforge.com.