Do you have to build for multiple store fronts each with their own SDKs?
This repo provides a set of abstract classes that can be overridden for DRM specific features such as achievements, leaderboards, rich presence, and cloud save. This allows you to use these features easily regardless of the storefront/distribution when you have multiple distributions simultaneously.
- Access achievements, leaderboards, rich presence and other features regardless of the distribution
- Easily extendable
- Add new stores e.g. Steam, GOG, Discord
- Add new features e.g. cloud save
- Accounts for some store fronts not offering certain features e.g. cloud save for GOG
// Example call to trigger achievements.
DRMManager.Store.GetComponent<DRMAchievements>()?.Unlock("Completed Level");
// Example call to submit leaderboard score.
DRMManager.Store.GetComponent<DRMLeaderboard>()?.SubmitScore("Level 6 Leaderboard", 10);
// Example call to set rich presence state.
DRMManager.Store.GetComponent<DRMRichPresence>()?.SetState("steam_display", "In level 6");
- A store must derive from
Winglett.DRM.Store
and override the abstract methodCreateInitializer()
and the propertyID
. - Create components deriving from
Winglett.DRM.DRMComponent
. - Create a constructor and call
RegisterComponent()
for any DRM feature you wish to use with this store. - Add a custom define to
StandaloneStoreFront.cs
to set the selected Store in the build. - Add the
DRM
script to a gameObject in your scene. SetEditorStoreFront
to theID
of the store you wish to test for. It's important that thisID
matches theID
set in the store script.
public static class StandaloneStoreFront
{
public static string GetStandaloneStoreFrontID()
{
#if BUILD_DIST_STEAM
return "Steam";
#elseif BUILD_DIST_GOG
return "GOG";
#elseif BUILD_DIST_YOUR_DISTRIBUTION_HERE
return "Your Store ID";
#endif
return "";
}
}
// How to make a new store
public class Store_Steam : Store
{
#region ----PROPERTIES----
public override string ID => "Steam";
#endregion
public Store_Steam()
{
RegisterComponent<SteamAchievements>();
}
protected override DRMInitialize CreateInitializer() => new SteamInitializer();
}
// How to initialize a store
public class SteamInitializer : DRMInitialize
{
public override void Connect() => Debug.Log("Connecting to steam");
public override void OnConnect() => Debug.Log("Successfully connected to steam");
public override void Disconnect() => Debug.Log("Disconnected from steam");
public override void Update() => Debug.Log("Update Steam callbacks");
}
// How to use components
public class SteamAchievements : DRMAchievements
{
public override void Unlock() => Debug.Log("Achievement Unlocked");
public override void Clear() => Debug.Log("Achievement Cleared");
}
- New components must derive from
Winglett.DRM.DRMComponent
. - Add abstract or virtual methods to be overriden by each store.
public abstract class DRMAchievements : DRMComponent
{
public abstract void Unlock(string id);
public abstract void Clear(string id);
}
This repo works well with Super Unity Build. It allows you to setup multiple distributions and check for these in code with custom defines.