Adapters

Abstraction layer for pluggable multiplayer service backends in the Network system. Defines the IServiceAdapter interface that all service implementations must satisfy, enabling the network system to support multiple providers (Unity Gaming Services, Steam, Epic) behind a single API.

Architecture

spinner

Data Flow

spinner

Key Concepts

Concept
Description

IServiceAdapter

Interface defining the contract for all multiplayer service backends — initialize, authenticate, and manage sessions

NetworkServiceType

Enum identifying the active service provider (UNITY, STEAM, EPIC)

UnityServiceAdapter

Concrete adapter implementing IServiceAdapter using Unity Gaming Services (Authentication + Multiplayer)

UnityNetworkSession

Concrete NetworkSession wrapping Unity's ISession with leave, kick, and refresh capabilities

UnityThreadUtils

Internal utility that captures Unity's main thread context via reflection, required before UnityServices.InitializeAsync()

Extension Pattern

To add a new service backend (e.g., Steam):

  1. Create a class implementing IServiceAdapter

  2. Set ServiceType to the corresponding NetworkServiceType enum value

  3. Implement all async methods using the platform's SDK

  4. Create a concrete NetworkSession subclass for the platform's session type

  5. Register the adapter in NetworkService for the new NetworkServiceType

Classes

Class
Description

Interface defining the multiplayer service backend contract

Unity Gaming Services implementation of IServiceAdapter

NetworkSession implementation wrapping Unity's ISession

Reflection-based utility for capturing Unity's main thread context

See Also

Last updated