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

Text Input

Gersh Payzer edited this page May 23, 2018 · 2 revisions

The textbox control allows viewers to input text to your game.

Interactive Studio

In Interactive Studio, you can add a new Textbox by selecting the Textbox control and adding it to your project:

Unity

In Unity, there is both a polling style API that can be called from your Update function as well as an event-based API.

Polling

If you want to get text input from your game's update loop, you can write the following code:

        if (MixerInteractive.HasSubmissions("MyTextBox"))
        {
            var results = MixerInteractive.GetText("MyTextBox");
            foreach (InteractiveTextResult result in results)
            {
                string userWhoGuessed = result.Participant.UserName;
                string guess = result.Text;
            }
        }

Event

If you prefer you can also listen for text input through the OnInteractiveTextControl event.

        MixerInteractive.OnInteractiveTextControlEvent += OnInteractiveTextControlEvent;

        private void OnInteractiveTextControlEvent(object sender, Microsoft.Mixer.InteractiveTextEventArgs e)
        {
            string viewName = e.Participant.UserName;
            string text = e.Text;
        }