internal void OnUpdate() { if (!reportedXRStateSwitch) { reportedXRStateSwitch = true; OnXRChange?.Invoke(xrState, viewsCount, leftRect, rightRect); } if (!updatedControllersOnEnd) { updatedControllersOnEnd = true; UpdateControllersOnEnd(); } if (visibilityStateChanged) { visibilityStateChanged = false; OnVisibilityChange?.Invoke(visibilityState); } if (this.xrState == WebXRState.NORMAL) { return; } UpdateXRCameras(); bool hasHandsData = false; if (OnHandUpdate != null && this.xrState != WebXRState.NORMAL) { if (GetHandFromHandsArray(0, ref leftHand)) { OnHandUpdate?.Invoke(leftHand); } if (GetHandFromHandsArray(1, ref rightHand)) { OnHandUpdate?.Invoke(rightHand); } hasHandsData = leftHand.enabled || rightHand.enabled; } if (!hasHandsData && OnControllerUpdate != null && this.xrState != WebXRState.NORMAL) { if (GetGamepadFromControllersArray(0, ref controller1)) { OnControllerUpdate?.Invoke(controller1); } if (GetGamepadFromControllersArray(1, ref controller2)) { OnControllerUpdate?.Invoke(controller2); } } if (OnViewerHitTestUpdate != null && this.xrState == WebXRState.AR) { if (GetHitTestPoseFromViewerHitTestPoseArray(ref viewerHitTestPose)) { OnViewerHitTestUpdate?.Invoke(viewerHitTestPose); } } }
//do nothing #else void Update() { bool isVRActive = XRSettings.isDeviceActive; //tells us whether the device is attached (not necessarily if it is being worn or used.) if (isVRActive && !previousIsVRActive) { OnXRChange.Invoke(WebXRState.VR, 2, new Rect(), new Rect()); } if (!isVRActive && previousIsVRActive) { OnXRChange.Invoke(WebXRState.NORMAL, 1, new Rect(), new Rect()); } previousIsVRActive = isVRActive; }
public void setXrState(WebXRState state, int viewsCount, Rect leftRect, Rect rightRect) { this.xrState = state; viewerHitTestOn = false; OnXRChange?.Invoke(state, viewsCount, leftRect, rightRect); }