-
Notifications
You must be signed in to change notification settings - Fork 23
Meta properties The ability to to tweak parameters without updating your game
Metaproperties allow you to set values on interactive controls that aren't hard-coded into your game. This means you can update those values quickly, without resubmitting your game to the store. For example, let's say you have a button that gives health to the player, but you aren't sure how much health you want to give. You release your game and find out that this button is making the game too easy for streamers. You can create a meta-property on your Give Health button that specifies how much health to give. Then you can change that value anytime without having to rebuild or resubmit your game.
- Go to Interactive Studio and create a new project.
- Name the project "Metaproperties Test" and set the game to "Other".
- Add a new button control. a. Set the Text property to "MyButton". b. Scroll down the to the Meta Properties section and click the Add Property button.
- In the Create Meta Property dialog, use the following values: a. Name: "Speed" b. Type: Number c. Value: 1
- Click Save on the dialog.
- Click Save on the project.
- In Unity, make sure you have the InteractivityManager prefab added to your scene and link the project you just created in Interactive Studio with your Unity game. For more information read Getting Started.
- Put an empty GameObject in your scene.
- Add a C# script file named 'MetaPropertiesTest.cs'. Paste the following code into the file:
using UnityEngine;
public class MetaPropertiesTest : MonoBehaviour {
private float speed;
// Use this for initialization
void Start () {
MixerInteractive.OnGoInteractive += OnGoInteractive;
MixerInteractive.GoInteractive();
}
private void OnGoInteractive(object sender, Microsoft.Mixer.InteractiveEventArgs e)
{
speed = System.Convert.ToSingle(MixerInteractive.GetControl("MyButton").MetaProperties["Speed"]);
}
// Update is called once per frame
void Update () {
}
}
- Press play in the Unity editor.
- You will see a button appear on your channel page and if you set a breakpoint on the following line:
speed = System.Convert.ToSingle(MixerInteractive.GetControl("MyButton").MetaProperties["Speed"]);
You will see the value of speed is 1, which was the value you set in Interactive Studio.
Metaproperties are powerful because after you have released your game, you can go to Interactive Studio and change the value of Speed from 1 to 2 and your game will get the value of 2 without you having to rebuild your game or resubmit it to the store.