Beamable Documentation

Welcome! Here is everything you need to get setup and become a Beamable expert.

Begin with the Getting Started section, learn more about Beamable features in the Manual, and check out the Script Reference APIs for advanced workflows.

Choose from the following...













.








.

Leaderboard - Sample

Allow player to manage leaderboard

Overview

Welcome to the "A Beamable Clicker" (ABC) game.

This downloadable sample project showcases the Beamable Leaderboard Flow FeatureFeature - An individual aspect of the Beamable product used to create a great user experience.

In this game, button clicks grow trees. Click as many times as possible
within the time limit.

This document and the sample project allow game makers to understand and apply the benefits of a LeaderboardLeaderboard - A list of high scores by all players of a game in game development. Or watch this video.

Download

These learning resources provide a better way to build live games in Unity.

Source

Detail

  1. Download the Leaderboard ABC Sample Project
  2. Open in Unity Editor ( Version 2019.4 LTS )
  3. Open the Beamable Toolbox
  4. Sign-In / Register To Beamable. See Step 1 - Getting Started for more info
  5. Open the Content Manager Window and click "Publish". See Content Manager for more info
  6. Open the 1.Intro Scene
  7. Play The Scene: Unity → Edit → Play

Note: Each sample project is compatible with Mac & Windows and includes the Beamable SDK. Each sample project requires internet connectivity.

Screenshots

The player navigates from the Intro Scene to the Game Scene, where all the action takes place. The Leaderboard scene shows the high scores by all players of the game.

Intro Scene

Game Scene

Leaderboard Scene

Project

Player Experience Flowchart

Here is the high level execution flow of user input and system interactions.

Game Maker User Experience

During development, the game maker's user experience is as follows. There are 3 major parts to this game creation process.

Steps

Follow these steps to get started.

These steps are already complete in the sample project. The instructions here explain the process.

📘

Related Feature

The background info and basic functionality are covered in the feature page. See Leaderboard Flow for more info.

Step 1. Setup The Project

Step

Detail

  1. Install the Beamable SDK and Register/Login

• See Step 1 - Getting Started for more info

Step 2. Create Content

Step

Detail

  1. Create CurrentScore Stat Object

• See Adding Stats for more info

  1. Create HighScore Stat Object

• See Adding Stats for more info

  1. Open the Content Manager Window

• Unity → Window → Beamable → Open Content Manager

  1. Create the "Leaderboard" content
• Select the content type in the list • Press the "Create" button • Populate the content name
  1. Populate all data fields

NOTE: With Write_self set as true the LeaderboardService allows the game client to set the score with C#. This is required for the sample game project.*

  1. Save the Unity Project

• Unity → File → Save Project

Best Practice: If you are working on a team, commit to version control in this step.

  1. Publish the content

• Press the "Publish" button in the Content Manager Window

Step 3. Create Game Code

Name

Detail

  1. Create C# game-specific logic

• Implement game logic
• Handle player input events
• Render graphics & sounds

Note: This represents the bulk of the development effort. The details depend on the specifics of the game project.

  1. Play the 1.Intro Scene

• Unity → Edit → Play

  1. Enjoy the game!

• Can you beat the high score?
• Checkout the Leaderboard

  1. Stop the Scene

• Unity → Edit → Stop

Code

Here are a few highlights from the project's major classes.

In the interest of brevity, these code embeds are incomplete. Download the project to see the complete code.

The IntroSceneManager uses Beamable's ConnectivityService to check internet availability.

namespace Beamable.Samples.ABC
{
   public class IntroSceneManager : MonoBehaviour
   {
      //  Fields ---------------------------------------
      private IBeamableAPI _beamableAPI = null;

      //  Unity Methods   ------------------------------
      protected void Start()
      {
         Beamable.API.Instance.Then(beamableAPI =>
         {
            _beamableAPI = beamableAPI;

            _beamableAPI.ConnectivityService.OnConnectivityChanged += ConnectivityService_OnConnectivityChanged;
            ConnectivityService_OnConnectivityChanged(_beamableAPI.ConnectivityService.HasConnectivity);
         });
      }

      //  Event Handlers -------------------------------
      private void ConnectivityService_OnConnectivityChanged(bool isConnected)
      {
         //React to changes in connectivity
      }
    
      //  Other Code (Not Shown) ...
     
   }
}

Inspector

Here is the GameSceneManager.cs main entry point for the Game Scene interactivity.

The "Leaderboard" reference is easily configurable

Here is the Configuration.cs holding high-level, easily-configurable values used by various areas on the game code.

🚧

Gotchas

Here are hints to help explain some of the trickier concepts.

• While the name is similar, this Configuration.cs
is wholly unrelated to Beamable's Configuration Manager.

The "Configuration" values are easily configurable

Optional: Game Makers may experiment with new Game Duration values to allow the player's turn to occur faster or slower.

Code

The GameSceneManager uses Beamable's StatBehaviour to set/get player-specific stored values and uses Beamable's LeaderboardService upon victory to submit the player-specific score.

namespace Beamable.Samples.ABC
{
   public class GameSceneManager : MonoBehaviour
   {
      //  Fields ---------------------------------------
      [SerializeField]
      private TreeView _treeView = null;

      [SerializeField]
      private StatBehaviour _currentScoreStatBehaviour = null;

      private IBeamableAPI _beamableAPI = null;

      //  Unity Methods   ------------------------------
      protected void Start ()
      {
         _currentScoreStatBehaviour.OnStatReceived.AddListener(CurrentScoreStatBehaviour_OnStatReceived);

         Beamable.API.Instance.Then(beamableAPI =>
         {
            _beamableAPI = beamableAPI;
         }
      }

      //  Other Methods --------------------------------
      private void SetLeaderboardScore(LeaderboardContent leaderboardContent, double score)
      {
         _beamableAPI.LeaderboardService.SetScore(leaderboardContent.Id, score);
      }

      //  Event Handlers -------------------------------
      private void CurrentScoreStatBehaviour_OnStatReceived(string currentScore)
      {
         float targetHighScore = 30;
         float growthPercentageOf100 = (100 * Int32.Parse(currentScore)) / targetHighScore;
         _treeView.GrowthPercentage = Mathf.Clamp01(growthPercentageOf100 / 100);
      }
     
      //  Other Code (Not Shown) ...
     
   }
}

Additional Experiments

Here some optional experiments game makers can perform with the sample project.

Did you complete all the experiments with success? We'd love to hear about it. Contact us.

Difficulty

Scene

Name

Detail

Beginner

Game

Tweak Configuration

• See Assets/ScriptableObjects/Configuration.asset.

  1. Change timing of game play and animations

Beginner

Game

Add new Input

• The current game uses mouse-clicks as input for core game play.

  1. Add mode where user clicks the Spacebar or other key as input

Intermediate

Game

Add 3 Difficulty Levels

• The current game has a set difficulty and set level duration.

  1. Add difficulty levels
  2. Increase level duration

Advanced

Game

Add 3 Types of Trees

• The current game has one TreeUI which grows the tree from bottom to top out of blocks and uses scale and movement as growth effects.

  1. Add new trees
  2. Add new growth effects

Advanced

Here are a few advanced configuration options and workflows.

Using Beamable Stats

Beamable StatStat - Active data entity used for read/write of player states are a simple place to read/write info (Ex. How many characters does the player own?)

See Adding Stats for more info

📘

More Info

• Strictly speaking, this sample project's needs do not require Beamable StatStat - Active data entity used for read/write of player states.
• The feature is included in this sample project for educational purposes.

Managing Leaderboard Via Portal

The Portal allows the game maker to manage LeaderboardLeaderboard - A list of high scores by all players of a games.

See Leaderboard Flow for more info.

Learning Resources

These learning resources provide a better way to build live games in Unity.

Source

Detail

  1. Download the Leaderboard ABC Sample Project
  2. Open in Unity Editor ( Version 2019.4 LTS )
  3. Open the Beamable Toolbox
  4. Sign-In / Register To Beamable. See Step 1 - Getting Started for more info
  5. Open the Content Manager Window and click "Publish". See Content Manager for more info
  6. Open the 1.Intro Scene
  7. Play The Scene: Unity → Edit → Play

Note: Each sample project is compatible with Mac & Windows and includes the Beamable SDK. Each sample project requires internet connectivity.

Updated 11 days ago


Leaderboard - Sample


Allow player to manage leaderboard

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.