docs.unity3d.com
    Show / Hide Table of Contents

    Get started

    To begin using the Presence package, you must first set up an app identifier and initialize the service.

    Set up an app identifier

    To set up an app identifier, follow the steps in the Identity package starter guide.

    Initialize the service

    To initialize your service, see the following steps:

    1. In your PlatformServices script, update the PlatformServices class with public references to IRoomProvider<Room> and ISessionProvider and a private reference to PresenceManager.

       static PresenceManager s_PresenceManager;
      
       public static IRoomProvider<Room> RoomProvider => s_PresenceManager;
       public static ISessionProvider SessionProvider => s_PresenceManager;
      
    2. Initialize the services in the InitializeAsync method. The variables provided in the constructor are defined in the Identity authentication guide.

       public static async Task InitializeAsync()
       {
           // ...
      
           s_PresenceManager = new PresenceManager(AccessTokenProvider, playerSettings, s_CloudConfiguration);
      
           // ...
       }
      
    3. Shut down the services in the Shutdown method.

       public static void Shutdown()
       {
           // ...
      
           s_PresenceManager.Dispose();
           s_PresenceManager = null;
      
           // ...
       }
      

    Manage the package stripping level

    To avoid runtime errors when building with this package, follow these steps:

    1. In your Unity project window, go to Edit > Project settings.
      The Project setting window opens.
    2. Select the Player option.
    3. Scroll to the Additional Compiler Arguments section.
    4. Set the Managed stripping level option to:
    • Disabled
      or
    • Minimal (if the Disabled option isn't available)

    Managed Stripping Level dropdown

    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