This guide will show you how to setup the Platform Manager and get started with the enum Platforms API.
Install enum Platforms from the Unity Asset Store. See Installation for more info
Create a Platform Manager in your scene.
Create a new scene with a camera
Create Empty → AddComponent → PlatformManager
Rename the gameObject to PlatformManager
Click “Create settings for SystemPlatform” if settings have not been created
Click Play and verify SystemPlatform(Clone) appears under DontDestroyOnLoad in your Hierarchy
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.
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.
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());
}
});
}
}
Create an empty gameObject and add QuickStart.cs
Create a UI button to execute the function
Press Play and click your button to create a player
With the reference Platform Player object, you can now use functions of the player to access all features of enum Platforms!
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.