API reference

LocalMatchmaking Class

Extends MonoBehaviour
This class provides a ready-to-use encapsulation that leverages the OVRColocationSession APIs to host and discover local / nearby Colocation sessions and join them via Bluetooth and WiFi.
Comparing to networking framework based matchmaking: this workflow ensures users are all locally nearby, and there's no need for using Oculus user ids when colocating within the group (this requires working together with the Colocation block with the "Use Colocation Session" option enabled).
All players wish to participate in the same session need to have Bluetooth enabled and join the same WiFi network.
As the local session provided by OVRColocationSession is just a mechanism to find nearby players and send limited metadata for matchmaking, it doesn't really allow synchronizing networked objects and support multiplayer game logic. Hence, for the benefit of bootstrapping a local multiplayer session easily, this implementation also depends on the CustomMatchmaking block to create and join networked rooms provided by 3p networking frameworks (such as Photon Fusion2, Unity Netcode for GameObjects).
This class provides an automatic mechanism to host/join local sessions on Start() depending on whether an existing colocation sessions available.
For more information about the OVRColocationSession API, checkout the official documentation
If wish to explicitly host / join the session with own game UI, developers could also use several async functions provided to trigger manually.

Static Fields

OnSessionCreateFailed : readonly UnityEvent< string >
Event to notify when failed to create and advertise the colocation session.
string: failure reason, could be potentially used to display instruction to users
Signature
readonly UnityEvent<string> OnSessionCreateFailed
OnSessionCreateSucceeded : readonly UnityEvent< Guid >
Event to notify when a colocation session has been created and advertised successfully by the host.
Guid: group uuid that can be used to share anchors via OVRSpatialAnchor.ShareAsync
Signature
readonly UnityEvent<Guid> OnSessionCreateSucceeded
OnSessionDiscoverFailed : readonly UnityEvent< string >
Event to notify when failed to discover the colocation session.
string: failure reason, could be potentially used to display instruction to users
Signature
readonly UnityEvent<string> OnSessionDiscoverFailed
OnSessionDiscoverSucceeded : readonly UnityEvent< Guid >
Event to notify when a colocation session has been discovered successfully by the guest.
Guid: group uuid that can be used to retrieve anchors via OVRSpatialAnchor.LoadUnboundSharedAnchorsAsync
Signature
readonly UnityEvent<Guid> OnSessionDiscoverSucceeded

Methods

StartAsGuest ( stopAfterTimeout )
Manually start as guest, this will discover colocation sessions via the OVRColocationSession API, then stop after timeDiscoveringInSec if setting stopAfterTimeout is set to true.
Signature
async Task StartAsGuest(bool stopAfterTimeout=true)
Parameters
stopAfterTimeout: bool  Boolean to determine whether to automatically stop the discovery after timeDiscoveringInSec
Returns
async Task
StartAsHost ()
Manually start as host, this will create a networked room under the hood by CustomMatchmaking, and in turn this class listens for the networked room creation event then broadcast the room information via the OVRColocationSession API.
Signature
async Task StartAsHost()
Returns
async Task

Static Methods

StartAdvertisingColocationSession ( data )
Wraps around the OVRColocationSession function to start advertise the colocation session with the byte data.
The public events of OnSessionCreateSucceeded and OnSessionCreateFailed will be notified accordingly.
Signature
static async void StartAdvertisingColocationSession(byte[] data)
Parameters
data: byte[]  metadata that's included in the advertisement, could pass up to OVRColocationSession.Data.MaxMetadataSize bytes.
Returns
async void
StartDiscoveringColocationSessions ( onGroupFound )
Wraps around the OVRColocationSession function to start discovering local sessions with custom callback.
The public events of OnSessionDiscoverSucceeded and OnSessionDiscoverFailed will be notified accordingly.
Signature
static async void StartDiscoveringColocationSessions(Action< OVRColocationSession.Data > onGroupFound)
Parameters
onGroupFound: Action< OVRColocationSession.Data >  Custom callback to parse the data received from the local session advertisement.
Returns
async void
StopAdvertisingColocationSession ()
Wraps around the OVRColocationSession function to stop advertise the local session.
Signature
static async void StopAdvertisingColocationSession()
Returns
async void
StopDiscoveringColocationSessions ( onGroupFound )
Wraps around the OVRColocationSession function to stop discovering the local session.
Signature
static async void StopDiscoveringColocationSessions(Action< OVRColocationSession.Data > onGroupFound)
Parameters
onGroupFound: Action< OVRColocationSession.Data >  Custom callback to remove from the discovery subscription.
Returns
async void