void OnPreRender() { if (imagesEnabled) { LeapWebSocketController controller = _provider.GetLeapController(); long start = controller.Now(); while (!_requestedImage.IsComplete) { if (controller.Now() - start > ImageTimeout) { break; } } if (_requestedImage.IsComplete) { if (_eyeTextureData.CheckStale(_requestedImage, _requestedImage)) { _eyeTextureData.Reconstruct(_requestedImage, _requestedImage); } _eyeTextureData.UpdateTextures(_requestedImage, _requestedImage); } else if (!checkingImageState) { StartCoroutine(checkImageMode()); } } }
void OnDestroy() { StopAllCoroutines(); LeapWebSocketController controller = _provider.GetLeapController(); if (controller != null) { _provider.GetLeapController().DistortionChange -= onDistortionChange; } }
private IEnumerator waitForController() { LeapWebSocketController controller = null; do { controller = _provider.GetLeapController(); yield return(null); } while (controller == null); onController(controller); }
/** Calling this method stop the connection for the existing instance of a Controller, * clears old policy flags and resets to null */ protected void destroyController() { if (webController != null) { if (webController.IsConnected) { webController.ClearPolicy(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD); } webController.StopConnection(); webController = null; } }
private void onController(LeapWebSocketController controller) { controller.DistortionChange += onDistortionChange; //controller.Connect += delegate { // _provider.GetLeapController().Config.Get("images_mode", (Int32 enabled) => { // this.imagesEnabled = enabled == 0 ? false : true; // }); //}; if (!checkingImageState) { StartCoroutine(checkImageMode()); } }
void Update() { if (imagesEnabled) { Frame imageFrame = _provider.CurrentFrame; LeapWebSocketController controller = _provider.GetLeapController(); // _requestedImage = controller.RequestImages(imageFrame.Id, Image.ImageType.DEFAULT); } else if (!checkingImageState) { StartCoroutine(checkImageMode()); } }
void OnDisable() { StopAllCoroutines(); LeapWebSocketController controller = _provider.GetLeapController(); if (controller != null) { _provider.GetLeapController().DistortionChange -= onDistortionChange; } LeapVRCameraControl.OnLeftPreRender -= ApplyCameraProjectionValues; LeapVRCameraControl.OnRightPreRender -= ApplyCameraProjectionValues; }
void OnEnable() { LeapWebSocketController controller = _provider.GetLeapController(); if (controller != null) { onController(controller); } else { StartCoroutine(waitForController()); } LeapVRCameraControl.OnLeftPreRender += ApplyCameraProjectionValues; LeapVRCameraControl.OnRightPreRender += ApplyCameraProjectionValues; }
/** Create an instance of a Controller, initialize its policy flags * and subscribe to connection event */ protected void createController() { if (webController != null) { destroyController(); } webController = FindObjectOfType <LeapWebSocketController>(); if (webController.IsConnected) { initializeFlags(); } else { webController.Device += onHandControllerConnect; } }
protected void Start() { if (provider.IsConnected()) { deviceInfo = provider.GetDeviceInfo(); LeapVRCameraControl.OnValidCameraParams += onValidCameraParams; if (deviceInfo.type == LeapDeviceType.Invalid) { Debug.LogWarning("Invalid Leap Device -> enabled = false"); enabled = false; return; } } else { StartCoroutine(waitForConnection()); LeapWebSocketController controller = provider.GetLeapController(); //controller.Device += OnDevice; } }