Skip to content

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 at once.

License

Notifications You must be signed in to change notification settings

the-mr-matt/DRM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DRM

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.

Features

  • 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

Usage

Examples:

// 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");

Adding New Stores:

  1. A store must derive from Winglett.DRM.Store and override the abstract method CreateInitializer() and the property ID.
  2. Create components deriving from Winglett.DRM.DRMComponent.
  3. Create a constructor and call RegisterComponent() for any DRM feature you wish to use with this store.
  4. Add a custom define to StandaloneStoreFront.cs to set the selected Store in the build.
  5. Add the DRM script to a gameObject in your scene. Set EditorStoreFront to the ID of the store you wish to test for. It's important that this ID matches the ID 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");
}

Adding New Components:

  1. New components must derive from Winglett.DRM.DRMComponent.
  2. 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);
}

Super Unity Build

This repo works well with Super Unity Build. It allows you to setup multiple distributions and check for these in code with custom defines.

About

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 at once.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages