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

Getting started

Gersh Payzer edited this page May 26, 2017 · 40 revisions

This article explains how to use the plugin to create an interactive game project in Unity. An interactive game enables viewers to directly control the environment in and around streamers' broadcasts by interacting with the UI controls displayed.

Import Mixer SDK into Unity

  • Download the Mixer SDK from the Unity Asset Store.
  • 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 MixerInteractive folder will be created under the Assets folder in your Unity project.

Create your first Mixer Interactive scene

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

  • Open the Mixer 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 Mixer service

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

  • Copy the Project Version ID to your clipboard.
  • Open the Mixer menu and select Open Mixer Editor.
  • Paste the Version ID from the earlier step into the Version ID field of the Mixer 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 Mixer 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 HelloMixer.cs.
  • Open the newly created HelloMixer.cs script. Add MixerInteracive.GoInteractive() to the Start function as shown below. MixerInteracive.GoInteractive is the API method to connect to the interactivity service.
void Start() {
    MixerInteracive.GoInteractive();
}
  • Go to the Update function and add a call to receive input from the "GiveHealth" button you've created earlier.
void Update() {
   if (MixerInteracive.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://mixer.com/go.
  • Open a web browser and go to your Mixer channel: http://mixer.com/.
  • 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