Platform Player is the core of enum Platforms. Create Platform Player objects to represent players on your target platform(s) and use platform features. The PlatformPlayer.cs script methods focus on supported intersecting features that today’s platforms offer.

Code Sample - PlatformPlayer.Create()

Call PlatformPlayer.Create(callback) to create a player for the platform selected on your Platform Manager

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());
        }
    });
}

Player Player prefabs

Ex: Steam Player(Clone) created after calling PlatformPlayer.Create() with Steam selected in the Platform Manager

Untitled

Player Creation Flowchart

This chart describes the logic for creating a platform player using PlatformPlayer.Create()

Support Multiple Players

Multiplatform Support

[SerializeField]
Platform platform1, platform2;

PlatformPlayer playerOnPlatform1, playerOnPlatform2;

private void Start()
{
    Platform.CreatePlatform(platform1, false, false, (platform, result) =>
    {
        if(result == Platform.CreateResult.Success)
        {
            //Create a player on platform 1
            PlatformPlayer.CreatePlayer(platform, (player, result) =>
            {
                if(result == PlatformPlayer.CreateResult.Success)
                {
                    //cache platform1 player object here
                    this.playerOnPlatform1 = player;
                }                        
            });
        }
    });

    Platform.CreatePlatform(platform2, false, true, (platform, result) =>
    {
        if(result == Platform.CreateResult.Success)
        {
            //Create a player on platform 2
            PlatformPlayer.CreatePlayer(platform, (player, result) =>
            {
                if(result == PlatformPlayer.CreateResult.Success)
                {
                    this.playerOnPlatform2 = player;
                }
            });
        }
    });
}
}