docs.unity3d.com
    Show / Hide Table of Contents

    Sample: Join voice chats in rooms

    You can use this sample to join the voice chat inside a room.

    Prerequisites

    Before you use the this sample, you must have the following:

    • An installed Presence package
    • An installed Vivox package
    • An installed Identity package
    • An installed Storage package
    • A valid Unity ID
    • A Unity Cloud scene associated with your Unity ID
    • Used the monitor and join rooms sample

    Note: While the Presence service doesn't depend on the Storage and Identity services directly, they are used in the sample to control the authentication flow.

    Overview

    If you want to build a sample that uses voice, you need to set up the Microphone Usage Description option.

    1. Inside your Unity project Window, go to Edit > Project Settings.
      The Project Settings window opens.
    2. In the Project Setting window, select Player > Other Settings.
    3. In Other Settings, scroll to the Mac Configuration section until you reach the Microphone Usage Description* field.
    4. In the Microphone Usage Description* field, enter your description.

    Installation

    To install this sample, see the following steps:

    1. Inside your Unity project window, go to Package Manager > Unity Cloud Presence.
    2. Expand the Samples section and select Import next to the Voice sample.
      Screenshot of the samples import section of the package manager window

    After the import process is complete, you can view your imported assets under the Assets/Samples/Unity Cloud Presence folder.
    Screenshot of the imported sample

    Join a voice chat in a room

    This sample shows you how to join a voice chat in a specific room.

    For a better user experience, you can join a room from multiple clients. To join a room from multiple clients, see the following steps:

    • Run the sample on two machines and join the same room
    • Build the sample scene and run the build at the same time as the sample in the Editor
    • Run the sample in two instances of the Unity Editor at the same time

    Launch the sample

    To launch the sample, see the following steps:

    1. Go to Assets/Samples/Unity Cloud Presence/<package-version>/Voice/Scenes/VoiceSample.unity and run the scene. If this is your first time launching the sample, make sure to sign in with your Unity ID account and that you have a Unity Cloud scene created. For more information on creating a Unity Cloud scene, see the Storage package documentation.
    2. Select and join a room as demonstrated in the Monitor and Join Rooms sample.

    Join a voice chat in the sample

    To join a voice chat, select Join Voice inside a room. You are added to the participant list and your voice chat updates as you speak.
    Screenshot of voice chat

    You can mute yourself to stop broadcasting your voice. As other participants join the voice chat, you can speak to them directly.

    Main components

    This section describes the scripts that make up the main components of this sample.

    Voice manager script

    The VoiceService script shows you how to do the following:

    • Interact with the VoiceService class to join or leave the voice chat, and to synchronize your muted flag
    • Register the VoiceService to receive events from other voice participants in the room

    To open the VoiceManager sample script, go to your Assets/Samples/Unity Cloud Presence/<package-version>/Voice/Scripts/VoiceManager.cs file.

    Troubleshoot

    The automatic browser redirection doesn't work

    If you run the sample in the Unity Editor, you should see the following page after you successfully login through your browser.

    Login Successful

    If you aren't automatically redirected to the Editor and nothing happens when you select Launch Application, return to the Editor. This should continue the authentication process.

    Mouse input isn't registered

    This sample isn't created to run with the Input System package. If you are using this package in your project, your mouse selections may not be detected.

    To fix this, set your project to support both the built-in input system as well as the Input System package: go to Edit > Project Settings > Player and set Active Input Handling to Both.

    Input system settings

    Missing dependency to com.unity.services.vivox package

    As mentioned at the top of this page, the Voice sample has a dependency on the Vivox package.

    To fix this, follow the Install Vivox section of installation guide.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023