Player Centric API - Overview

Provide power and flexibility to the game maker

Overview

The "Beamable SDK for Unity" provides a main entry point to Beamable. This entry point and API will change to be more powerful and user-friendly.

Legacy Beamable API

As outlined in Learning Fundamentals the legacy API offers flexible API reference syntax of Async / Await, Callbacks, & Coroutines.

private async void InitializeLegacyAPI()
{
    var beamableAPI = await Beamable.API.Instance;
    Debug.Log($"beamableAPI.User.id = {beamableAPI.User.id}");
}

After that setup, game makers use the beamableAPI object as the main entry-point to Beamable functionality. Limitations of this API include that it relates to exactly one local player and most Beamable functionality within must be called asynchronously.

Beamable Player-Centric API

The Beamable Player-Centric API continues to offer a flexible API reference syntax of Async / Await, Callbacks, Coroutines, as well as Synchronous.

private async void InitializeBeamContext()
{
    var _context = BeamContext.Default;
    //The OnReady callback can be used to explicitly wait for initialization to complete.
    //However, it can be omitted in a synchronous function.
    await _context.OnReady;
    Debug.Log($"_context.PlayerId = {_context.PlayerId}");
}

Benefits

BenefitsLegacy APIPlayer-Centric API
Flexible creation syntax
(Async / Await, Callbacks, & Coroutines)
✔️✔️
Flexible service method calls syntax
(Async / Await, Callbacks, Coroutines & Synchronous)
✔️
Supports 2+ Local Players✔️
Designed for Testability✔️
Optimized for Lazy Initialization✔️

Migration

Game makers with existing Beamable projects which are using the legacy Beamable API are encouraged to migrate to the Beamable Player-Centric API

For the simplest migration instructions;

  • Replace var beamableAPI = await Beamable.API.Instance; with var beamContext = BeamContext.Default;.
  • APIs and services are accessed very similarly as well, since a BeamContext instance has an Api variable, with access to all the same services as Beamable.API. This is documented further in the Player Centric API - Dependency Injection documentation.