// Update is called once per frame void Update() { #if UNITY_EDITOR if (Application.isPlaying) { return; } #endif if (Interop.WVR_IsInputFocusCapturedBySystem()) { if (!isFocusCapturedBySystemLastFrame) { foreach (ControllerInstance t in ctrInstanceList) { bool ret = ForceSetActiveOfEmitter(t, false); } } isFocusCapturedBySystemLastFrame = true; return; } if (isFocusCapturedBySystemLastFrame) { systemEventType = WaveVR_Utils.WVR_GetFocusedController(); PrintDebugLog("back from overlay() Focus controller: " + systemEventType); isFocusCapturedBySystemLastFrame = false; this.toSetActiveOfEmitter = true; } if (this.ctrInstanceList.Count < 1) { this.lastEventType = WVR_DeviceType.WVR_DeviceType_Invalid; return; } PrintIntervalLog(() => "Controller instance: " + ctrInstanceList.Count + ", Focus controller: " + systemEventType); if (this.ctrInstanceList.Count == 1) { ControllerInstance t = ctrInstanceList [0]; this.systemEventType = t.type; if (this.isCtrInstanceUpdated) { this.isCtrInstanceUpdated = !this.isCtrInstanceUpdated; PrintDebugLog("Update() Controller focus changes to " + this.systemEventType); } } else // count > 1 { if (this.systemEventType == WVR_DeviceType.WVR_DeviceType_Controller_Right) { if (WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Left).GetPressUp(WVR_InputId.WVR_InputId_Alias1_Digital_Trigger) || WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Left).GetPressUp(WVR_InputId.WVR_InputId_Alias1_Trigger)) { this.systemEventType = WVR_DeviceType.WVR_DeviceType_Controller_Left; PrintDebugLog("Update() Controller focus changes from Right to Left, set to runtime."); } } if (this.systemEventType == WVR_DeviceType.WVR_DeviceType_Controller_Left) { // Listen to right if (WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetPressUp(WVR_InputId.WVR_InputId_Alias1_Digital_Trigger) || WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetPressUp(WVR_InputId.WVR_InputId_Alias1_Trigger)) { this.systemEventType = WVR_DeviceType.WVR_DeviceType_Controller_Right; PrintDebugLog("Update() Controller focus changes from Left to Right, set to runtime."); } } } if (this.lastEventType != this.systemEventType || this.connectionUpdated) { this.lastEventType = this.systemEventType; PrintDebugLog("Update() current focus: " + this.systemEventType); this.connectionUpdated = false; if (this.systemEventType == WVR_DeviceType.WVR_DeviceType_Controller_Right) { activateEventSystem(WVR_DeviceType.WVR_DeviceType_Controller_Right, true); activateEventSystem(WVR_DeviceType.WVR_DeviceType_Controller_Left, false); } if (this.systemEventType == WVR_DeviceType.WVR_DeviceType_Controller_Left) { activateEventSystem(WVR_DeviceType.WVR_DeviceType_Controller_Right, false); activateEventSystem(WVR_DeviceType.WVR_DeviceType_Controller_Left, true); } WaveVR_Utils.WVR_SetFocusedController(this.systemEventType); this.toSetActiveOfEmitter = true; } setActiveOfEmitter(); }