docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Sample: Monitor and join rooms in Unity Cloud projects

    This sample shows you how to monitor, join, and leave rooms attached to Unity Cloud projects.

    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.

    Before you start

    To use the sample, you require the following:

    • Installed Presence package
    • Installed Identity package
    • A valid Unity ID
    • A Unity Cloud Project associated with your Unity ID
    Note

    While the Unity Cloud Presence package doesn't depend on the Unity Cloud Identity package, it is used in this sample to control the authentication process.

    Install the sample

    To install this sample, see the following steps:

    1. Inside your Unity Editor Project window, go to Package Manager > Unity Cloud Presence.
    2. Expand the Samples section.
    3. On the right of the Room Monitoring sample, select Import.
      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

    Launch the sample

    To launch the sample, see the following steps:

    1. Go to Assets/Samples/Unity Cloud Presence/<package-version>/Room Monitoring/Scenes/RoomMonitoringSample.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 project created.
    2. Select Launch Scene.

    Monitor a room in the sample

    To monitor a room in the sample, see the following steps:

    1. Go to Room Manager and select a organization in the first dropdown.
    2. In the second dropdown, select the project you want to monitor.
      Screenshot of selecting a room
    3. Go to the list of participants to see the participants currently in the room attached to the project you selected.
      Screenshot of a room participant

    Join and leave a room in the sample

    To join and leave a room in the sample, see the following steps:

    1. To join a room, select a room and select Join Room. The list of participants in the room updates to include your participant.
      Screenshot of a joined room
    2. To leave a room, select Leave Room. You can also automatically leave by selecting another project.

    Main components

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

    Platform services script

    The PlatformServices class initializes and disposes of dependencies required by the Unity Cloud Presence samples. You can use this class to manage the Unity Cloud services and dependencies you use in your application.

    To open the platform services script, go to your Assets/Samples/Unity Cloud Presence/<package-version>/Shared/Scripts/Services/PlatformServices.cs file.

    The PlatformServices class has two accompanying classes called PlatformServicesInitialization and PlatformServicesShutdown that call the initialization and shutdown methods through Unity's standard Monobehaviour methods Awake(), Start() and OnDestroy().

    Login manager script

    The LoginManager class manages the login flow for signing in with your Unity ID. For more information on authentication, see the Identity package documentation.

    To open the login manager script, go to your Assets/Samples/Unity Cloud Presence/<package-version>/Shared/Scripts/Login/LoginManager.cs file.

    Room manager script

    The RoomManager script shows you how to do the following:

    • Retrieve the Unity Cloud organizations and projects associated with your Unity ID.
    • Get a Room from a RoomProvider.
    • Monitor and join a selected room.

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

    Go further

    This section describes other actions you can perform with this sample.

    Monitor multiple rooms

    You can create a lobby to monitor and view participants in multiple rooms at the same time without joining them.

    Troubleshooting

    Refer to the troubleshooting section for help with sample issues.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)