SteamVR broadcasts several events that can be handled by registering via SteamVR_Events.<EventType>.Listen.
Best Practice: Always call Remove in OnDisable to avoid memory leaks or errors when components are destroyed.
Available Events
Initializing: Sent when the HMD's tracking status changes to or from Uninitialized.Calibrating: Sent when starting or stopping calibration.OutOfRange: Sent when losing or reacquiring absolute positional tracking.DeviceConnected: Sent when devices are connected or disconnected. Arguments: int deviceIndex, bool connectedStatus.
void OnEnable() {
SteamVR_Events.DeviceConnected.Listen(OnDeviceConnected);
}
void OnDisable() {
SteamVR_Events.DeviceConnected.Remove(OnDeviceConnected);
}
void OnDeviceConnected(int index, bool connected) {
// Handle connection
}