Skip to main content
Skip table of contents

Rapport Basic Sample Scene

image-20250909-010619.png

Rapport DemoUIController

The DemoUIController.cs script is a key example provided in the samples package. It demonstrates how to manage a Rapport session through a user interface. This script acts as a central hub, calling methods on the core RapportSession.cs component to control the session and manage the UI's state.

How it works

The DemoUIController script has a serialized field that holds a reference to a RapportSession component, which is the main component that handles the connection to the Rapport cloud.

The script's primary functions are:

  • Starting the Session: When the user clicks the "Start" button in the demo UI, the StartRapportSession() method is called. This method validates that a microphone is connected and then initiates the Rapport session by calling Session.StartSession() on the referenced RapportSession component.

  • Binding Outputs: After the session has successfully started, the WaitForSessionStart() coroutine is executed. This coroutine waits until the Session component is ready and then binds the outputs (audio and animation) to the respective Unity components. This is done by calling Session.BindPlayer(), which directs the real-time audio and animation data from the Rapport session to the OutputAudioSource and OutputAnimator in your scene.

  • Stopping the Session: When the "Stop" button is clicked, the StopRapportSession() method is called. This method simply calls Session.StopSession() on the RapportSession component, which properly closes the connection and ends the session.

By examining the DemoUIController script, you can see how to programmatically control a Rapport session and respond to its state changes within a Unity application

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.