Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Getting started

Joanna Lee edited this page May 3, 2017 · 40 revisions

This article explains how to create a Beam interactive game project in Unity. A Beam Interactive game enables viewers to directly control the environment in and around streamers' broadcasts by interacting with the UI controls displayed.

Import Beam SDK into Unity

  • Download the Beam SDK from the Unity Asset Store.
  • To import the Beam SDK, open the Unity Editor and select: Assets > Import Package > Custom Package. Locate your downloaded SDK package, select the package, and click Open. Leave all the files checked and click Import as shown in the screenshot below:

  • If the import process is successful, a Beam folder will be created under the Assets folder in your Unity project.

Create your first Beam Interactive scene

  • In the Unity editor, go to Beam > Prefabs, and drag the BeamManager prefab into your scene. We recommend that this prefab be the first asset you add into the scene.

  • Open the Beam menu and select Interactive Studio.
  • Create a new project and name it "HelloWorld". Then click Save.

  • Click the Build tab at the top of the Interactive Studio Editor as shown in the screenshot below:

  • Add a new scene called "default".
  • Add a new control. Make sure the control type is set to button (this is the default). Name the button "GiveHealth". This is the string is referenced in the game code.

  • Drop the button on the grid.
  • Click Save.

Link your game to the Beam service

  • Go to the Code tab at the top of the Interactive Studio Editor.

  • Copy the Project Version ID to your clipboard.
  • Open the Beam menu and select Open Beam Editor.
  • Paste the Version ID from the earlier step into the Version ID field of the Beam Editor.
  • Go back to the Code tab at the top of the Interactive Studio Editor and click on the go to Developer Lab link.

  • In Developer Lab, click on the Manage OAuth button to go to the OAuth Clients page.
  • On the OAuth Clients page, create a new OAuth client with the following information:
  • Copy the OAuth Client ID of the newly created client.
  • Go back to the Unity editor and open the Beam Editor. Paste the OAuth Client ID into the OAuth Client ID field.
  • Click on the Save project information button to save the settings.

Add interactivity into your scene

  • Go back to your scene in Unity and create a new empty GameObject in the hierarchy window.
  • Click on the newly created GameObject and then click on the Add Component button. Add a new C# script and name it HelloBeam.cs.
  • Open the newly created HelloBeam.cs script. Add Beam.GoInteractive() to the Start function as shown below. Beam.GoInteractive is the API method to connect to the Beam service.
void Start() {
    Beam.GoInteractive();
}
  • Go to the Update function and add a call to receive input from the "GiveHealth" button you've created earlier.
void Update() {
   if (Beam.GetButton("GiveHealth")) {
       Debug.Log("Player health increased.");
   }
}

Test your game

  • To test your set up, click on the Play button in the Unity editor.
  • Follow the instructions and enter the displayed code at http://beam.pro/go.
  • Open a web browser and go to your Beam channel: http://beam.pro/.
  • Click on the "GiveHealth" button.
  • If you have the Unity console open, you'll see "Player health increased." printed on the console.

Clone this wiki locally