This example code demonstrates how to handle events from onAirXR client.

using onAirXR.Server;

public class App : MonoBehaviour, AXRServer.EventHandler {
    private bool _registered;

    private void Update() {
				// AXRServer GameObject is instantiated when
				//   i) XR is first enabled or 
				//   ii) after the first frame if XR is initialized on startup.
        // Note that the instance is not destroyed until the application quits.
        if (_registered == false && AXRServer.instance != null) {
            AXRServer.instance.RegisterEventHandler(this);
            _registered = true;
        }
    }

    private void OnDestroy() {
        if (AXRServer.instance != null) {
            AXRServer.instance.UnregisterEventHandler(this);
        }
    }

    void AXRServer.EventHandler.OnConnect(AXRPlayerConfig config) {
				// called when a client is connected
        Debug.Log($"OnConnect: UserID = {config.userID}, place = {config.place}");
    }
    
    void AXRServer.EventHandler.OnActivate() {
				// called when user puts on headset
        Debug.Log("OnActivate");
    }

    void AXRServer.EventHandler.OnDeactivate() {
				// called when user takes off headset
        Debug.Log("OnDeactivate");
    }
    
    void AXRServer.EventHandler.OnDisconnect() {
				// called when the client is disconnected
        Debug.Log("OnDisconnect");
    }

    void AXRServer.EventHandler.OnUserdataReceived(byte[] data) {}
}

🏠  onAirXR Unity XR Plugin Developer Guide

Getting Started


System Requirements


Quick Start


Programming Guide


XR Plugin Settings


Input


Handle Client Events


Volumetric Streaming (BETA)


Build & Run


Build


Command Line Arguments