private void NuitrackManager_onHandsTrackerUpdate(nuitrack.HandTrackerData handTrackerData) { active = false; press = false; if (handTrackerData != null) { nuitrack.UserHands userHands = handTrackerData.GetUserHandsByID(CurrentUserTracker.CurrentUser); if (userHands != null) { if (currentHand == Hands.right && userHands.RightHand != null) { baseRect.anchoredPosition = new Vector2(userHands.RightHand.Value.X * Screen.width, -userHands.RightHand.Value.Y * Screen.height); active = true; press = userHands.RightHand.Value.Click; } else if (currentHand == Hands.left && userHands.LeftHand != null) { baseRect.anchoredPosition = new Vector2(userHands.LeftHand.Value.X * Screen.width, -userHands.LeftHand.Value.Y * Screen.height); active = true; press = userHands.LeftHand.Value.Click; } } } background.enabled = active; background.sprite = active && press ? pressSprite : defaultSprite; if (!active) { return; } Vector2 pointOnScreenPosition = cam.WorldToScreenPoint(transform.position); eventData.delta = pointOnScreenPosition - eventData.position; eventData.position = pointOnScreenPosition; raycastResults.Clear(); EventSystem.current.RaycastAll(eventData, raycastResults); ImageItem newButton = null; for (int i = 0; i < raycastResults.Count && newButton == null; i++) { newButton = raycastResults[i].gameObject.GetComponent <ImageItem>(); } if (newButton != selectedButton) { if (selectedButton != null) { selectedButton.OnPointerExit(eventData); } selectedButton = newButton; if (selectedButton != null) { selectedButton.OnPointerEnter(eventData); } } else if (selectedButton != null) { if (press) { if (eventData.delta.sqrMagnitude < dragSensitivity && !eventData.dragging) { eventData.dragging = true; selectedButton.OnPointerDown(eventData); } } else if (eventData.dragging) { eventData.dragging = false; selectedButton.OnPointerUp(eventData); } if (press) { selectedButton.OnDrag(eventData); } } }