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.
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());
}
});
}
Ex: Steam Player(Clone) created after calling PlatformPlayer.Create() with Steam selected in the Platform Manager
This chart describes the logic for creating a platform player using PlatformPlayer.Create()
Create() will invoke the platform login dialog or automatically login your player
Failed logins will result in the gameobject being destroyed
[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;
}
});
}
});
}
}