public void Click() { VerifyEventsArgs verifyArgs = new VerifyEventsArgs(); verifyArgs.isPointerInteractive = true; pointer.TriggerDown.Returns(true); pointer.Triggering.Returns(true); eventExecutor.GetEventHandler <IPointerClickHandler>(hitObject).Returns(hitObject); eventExecutor.ExecuteHierarchy <IPointerClickHandler>(hitObject, module.CurrentEventData, ExecuteEvents.pointerClickHandler).Returns(hitObject); ProcessHit(); verifyArgs.eventFlags = EventFlags.Down | EventFlags.Enter; VerifyEvents(verifyArgs); pointer.TriggerDown.Returns(false); pointer.Triggering.Returns(false); ProcessHit(); verifyArgs.eventFlags = EventFlags.Up | EventFlags.Click | EventFlags.Hover; VerifyEvents(verifyArgs); }
private void OnTouchingScrollHandler(GameObject currentScrollHandler, PointerEventData pointerData, Vector2 currentScroll, IGvrEventExecutor eventExecutor) { ScrollInfo scrollInfo = null; if (!scrollHandlers.ContainsKey(currentScrollHandler)) { scrollInfo = AddScrollHandler(currentScrollHandler, currentScroll); } else { scrollInfo = scrollHandlers[currentScrollHandler]; } currentScroll *= GetScrollDeltaMultiplier(scrollInfo); CalculationValue(GetScrollDeltaMultiplier(scrollInfo)); // Detect if we should start scrolling along the x-axis based on the horizontal slop threshold. if (CanScrollStartX(scrollInfo, currentScroll)) { scrollInfo.isScrollingX = true; } // Detect if we should start scrolling along the y-axis based on the vertical slop threshold. if (CanScrollStartY(scrollInfo, currentScroll)) { scrollInfo.isScrollingY = true; } if (scrollInfo.IsScrolling) { Vector2 clampedScroll = currentScroll; Vector2 clampedLastScroll = scrollInfo.lastScroll; if (!scrollInfo.isScrollingX) { clampedScroll.x = 0.0f; clampedLastScroll.x = 0.0f; } if (!scrollInfo.isScrollingY) { clampedScroll.y = 0.0f; clampedLastScroll.y = 0.0f; } Vector2 scrollDisplacement = clampedScroll - clampedLastScroll; UpdateVelocity(scrollInfo, scrollDisplacement); if (!ShouldUseInertia(scrollInfo)) { // If inertia is disabled, then we send scroll events immediately. pointerData.scrollDelta = scrollDisplacement; eventExecutor.ExecuteHierarchy(currentScrollHandler, pointerData, ExecuteEvents.scrollHandler); pointerData.scrollDelta = Vector2.zero; } } scrollInfo.lastScroll = currentScroll; }
private void UpdateInertiaScrollHandlers(bool touching, GameObject currentScrollHandler, PointerEventData pointerData, IGvrEventExecutor eventExecutor) { if (pointerData == null) { return; } // If the currentScrollHandler is null, then the currently scrolling scrollHandlers // must still be decelerated so the function does not return early. for (int i = 0; i < scrollingObjects.Count; i++) { GameObject scrollHandler = scrollingObjects[i]; ScrollInfo scrollInfo = scrollHandlers[scrollHandler]; if (!ShouldUseInertia(scrollInfo)) { continue; } if (scrollInfo.IsScrolling) { // Decelerate the scrollHandler if necessary. if (!touching || scrollHandler != currentScrollHandler) { float finalDecelerationRate = GetDecelerationRate(scrollInfo); scrollInfo.scrollVelocity *= Mathf.Pow(finalDecelerationRate, Time.deltaTime); } // Send the scroll events. pointerData.scrollDelta = scrollInfo.scrollVelocity * Time.deltaTime; eventExecutor.ExecuteHierarchy( scrollHandler, pointerData, ExecuteEvents.scrollHandler); } } pointerData.scrollDelta = Vector2.zero; }
private void OnTouchingScrollHandler(GameObject currentScrollHandler, PointerEventData pointerData, Vector2 currentScroll, IGvrEventExecutor eventExecutor) { ScrollInfo scrollInfo = null; if (!scrollHandlers.ContainsKey(currentScrollHandler)) { scrollInfo = AddScrollHandler(currentScrollHandler, currentScroll); } else { scrollInfo = scrollHandlers[currentScrollHandler]; } // Determine if we should start scrolling this scrollHandler. // This is true if the current scroll is outside of the slop threshold. if (CanScrollStart(scrollInfo, currentScroll)) { scrollInfo.isScrolling = true; } if (scrollInfo.isScrolling) { if (ShouldUseInertia(scrollInfo)) { UpdateVelocity(scrollInfo, currentScroll); } else { // If inertia is disabled, then we send scroll events immediately. pointerData.scrollDelta = currentScroll - scrollInfo.lastScroll; eventExecutor.ExecuteHierarchy(currentScrollHandler, pointerData, ExecuteEvents.scrollHandler); pointerData.scrollDelta = Vector2.zero; } } scrollInfo.lastScroll = currentScroll; }