This guide will show you how to setup the Platform Manager and get started with the enum Platforms API.

Setup the Platform Manager and configure a platform

  1. Install enum Platforms from the Unity Asset Store. See Installation for more info

  2. Create a Platform Manager in your scene.

    1. Create a new scene with a camera

    2. Create Empty → AddComponent → PlatformManager

    3. Rename the gameObject to PlatformManager

    4. Click “Create settings for SystemPlatform” if settings have not been created

      Untitled

  3. Click Play and verify SystemPlatform(Clone) appears under DontDestroyOnLoad in your Hierarchy

    Untitled

The System Platform is now selected and configured, you can begin using the API! To use another platform, ensure the Platform has been configured properly. An improperly configured platform gameObject will be destroyed and not appear in your heirarchy. See Supported Platforms for specific instructions per platform.

Creating a player

A PlatformPlayer must be created to use begin using features of the player’s account. Call PlatformPlayer.Create() to invoke the native login dialog or automatically login a player, depending on the platform. Successful login will create a PlatformPlayer gameObject in your scene. This workflow allows support for multi-user login if the platform allows it.

  1. Create a script called QuickStart.cs
  2. Copy and pase the code from below into your script
using UnityEngine;
using enumGames.Platforms;

public class QuickStart : MonoBehaviour
{
		PlatformPlayer player;

    public void CreatePlayer()
    {
				PlatformPlayer.CreatePlayer((player, result) =>
				{
					if (result == PlatformPlayer.CreateResult.Success)
					{
						//player created successfully - cache the player object
						this.player = player;
					}
					else
					{
						//failed to create player
						Debug.LogError("Failed to create player, result: " + result.ToString());
					}
				});
	}
}
  1. Create an empty gameObject and add QuickStart.cs

  2. Create a UI button to execute the function

    1. Right click heirarchy → UI → Button
    2. Change the text to say “Create Player”
    3. Assign QuickStart.CreatePlayer to the OnClick() event

    Untitled

    Untitled

  3. Press Play and click your button to create a player

    1. In your heirarchy, you should see the System Platform and the created System Player as a child

With the reference Platform Player object, you can now use functions of the player to access all features of enum Platforms!

Unlocking an achievement

Achievements are setup as scriptable objects. The scriptable object exposes fields for platform specific identifiers and allows you to link stat requirements to unlocking achievements.

  1. Create a new folder, Assets/Achievements