protected void CopyFromTo(PointerEventData @from, PointerEventData @to) { @to.position = @from.position; @to.delta = @from.delta; @to.scrollDelta = @from.scrollDelta; @to.pointerCurrentRaycast = @from.pointerCurrentRaycast; @to.pointerEnter = @from.pointerEnter; }
public void OnDrop(PointerEventData eventData) { }
public void OnPointerClick(PointerEventData eventData) { Application.OpenURL(url); }
public ButtonState GetButtonState(PointerEventData.InputButton button) { ButtonState tracked = null; for (int i = 0; i < m_TrackedButtons.Count; i++) { if (m_TrackedButtons[i].button == button) { tracked = m_TrackedButtons[i]; break; } } if (tracked == null) { tracked = new ButtonState { button = button, eventData = new MouseButtonEventData() }; m_TrackedButtons.Add(tracked); } return tracked; }
// walk up the tree till a common root between the last entered and the current entered is foung // send exit events up to (but not inluding) the common root. Then send enter events up to // (but not including the common root). protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget) { // if we have no target / pointerEnter has been deleted // just send exit events to anything we are tracking // then exit if (newEnterTarget == null || currentPointerData.pointerEnter == null) { for (var i = 0; i < currentPointerData.hovered.Count; ++i) ExecuteEvents.Execute(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerExitHandler); currentPointerData.hovered.Clear(); if (newEnterTarget == null) { currentPointerData.pointerEnter = newEnterTarget; return; } } // if we have not changed hover target if (currentPointerData.pointerEnter == newEnterTarget && newEnterTarget) return; GameObject commonRoot = FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget); // and we already an entered object from last time if (currentPointerData.pointerEnter != null) { // send exit handler call to all elements in the chain // until we reach the new target, or null! Transform t = currentPointerData.pointerEnter.transform; while (t != null) { // if we reach the common root break out! if (commonRoot != null && commonRoot.transform == t) break; ExecuteEvents.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerExitHandler); currentPointerData.hovered.Remove(t.gameObject); t = t.parent; } } // now issue the enter call up to but not including the common root currentPointerData.pointerEnter = newEnterTarget; if (newEnterTarget != null) { Transform t = newEnterTarget.transform; while (t != null && t.gameObject != commonRoot) { ExecuteEvents.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerEnterHandler); currentPointerData.hovered.Add(t.gameObject); t = t.parent; } } }
protected virtual void ProcessMove(PointerEventData pointerEvent) { var targetGO = pointerEvent.pointerCurrentRaycast.gameObject; HandlePointerExitAndEnter(pointerEvent, targetGO); }
private void CastRay() { if (Pointer == null || Pointer.PointerTransform == null) { return; } Vector2 currentPose = GvrMathHelpers.NormalizedCartesianToSpherical(Pointer.PointerTransform.forward); if (CurrentEventData == null) { CurrentEventData = new PointerEventData(ModuleController.eventSystem); lastPose = currentPose; } // Store the previous raycast result. RaycastResult previousRaycastResult = CurrentEventData.pointerCurrentRaycast; // The initial cast must use the enter radius. if (Pointer != null) { Pointer.ShouldUseExitRadiusForRaycast = false; } // Cast a ray into the scene CurrentEventData.Reset(); // Set the position to the center of the camera. // This is only necessary if using the built-in Unity raycasters. RaycastResult raycastResult; CurrentEventData.position = GvrMathHelpers.GetViewportCenter(); bool isPointerActiveAndAvailable = IsPointerActiveAndAvailable(); if (isPointerActiveAndAvailable) { ModuleController.eventSystem.RaycastAll(CurrentEventData, ModuleController.RaycastResultCache); raycastResult = ModuleController.FindFirstRaycast(ModuleController.RaycastResultCache); } else { raycastResult = new RaycastResult(); raycastResult.Clear(); } // If we were already pointing at an object we must check that object against the exit radius // to make sure we are no longer pointing at it to prevent flicker. if (previousRaycastResult.gameObject != null && raycastResult.gameObject != previousRaycastResult.gameObject && isPointerActiveAndAvailable) { if (Pointer != null) { Pointer.ShouldUseExitRadiusForRaycast = true; } ModuleController.RaycastResultCache.Clear(); ModuleController.eventSystem.RaycastAll(CurrentEventData, ModuleController.RaycastResultCache); RaycastResult firstResult = ModuleController.FindFirstRaycast(ModuleController.RaycastResultCache); if (firstResult.gameObject == previousRaycastResult.gameObject) { raycastResult = firstResult; } } if (raycastResult.gameObject != null && raycastResult.worldPosition == Vector3.zero) { raycastResult.worldPosition = GvrMathHelpers.GetIntersectionPosition(CurrentEventData.enterEventCamera, raycastResult); } CurrentEventData.pointerCurrentRaycast = raycastResult; // Find the real screen position associated with the raycast // Based on the results of the hit and the state of the pointerData. if (raycastResult.gameObject != null) { CurrentEventData.position = raycastResult.screenPosition; } else { Transform pointerTransform = Pointer.PointerTransform; float maxPointerDistance = Pointer.MaxPointerDistance; Vector3 pointerPos = pointerTransform.position + (pointerTransform.forward * maxPointerDistance); if (CurrentEventData.pressEventCamera != null) { CurrentEventData.position = CurrentEventData.pressEventCamera.WorldToScreenPoint(pointerPos); } else if (Camera.main != null) { CurrentEventData.position = Camera.main.WorldToScreenPoint(pointerPos); } } ModuleController.RaycastResultCache.Clear(); CurrentEventData.delta = currentPose - lastPose; lastPose = currentPose; // Check to make sure the Raycaster being used is a GvrRaycaster. if (raycastResult.module != null && !(raycastResult.module is GvrPointerGraphicRaycaster) && !(raycastResult.module is GvrPointerPhysicsRaycaster)) { Debug.LogWarning("Using Raycaster (Raycaster: " + raycastResult.module.GetType() + ", Object: " + raycastResult.module.name + "). It is recommended to use " + "GvrPointerPhysicsRaycaster or GvrPointerGrahpicRaycaster with GvrPointerInputModule."); } }
public void OnBeginDrag(PointerEventData date) { lasty = date.position.y;/// // print(lasty); }
public void OnPointerClick(PointerEventData eventData) { PlayPress(); }
public void OnPointerEnter(PointerEventData eventData) { PlaySelect(); }
/// <summary> /// Pressed /// </summary> public void OnPointerDown(PointerEventData eventData) { OnKeyPress.Invoke(); Image.color = pressColor; }
/// <summary> /// Released /// </summary> public void OnPointerUp(PointerEventData eventData) { OnKeyRelease.Invoke(); Image.color = srcColor; }
public void OnPointerClick(PointerEventData eventData) { ChangeColor(); }
public void OnPointerDown(PointerEventData e) { _isTouching = true; cam = e.pressEventCamera; OnDrag(e); }
// Modified version of BaseInputModule.HandlePointerExitAndEnter that calls EventExecutor instead of // UnityEngine.EventSystems.ExecuteEvents. private void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget) { // If we have no target or pointerEnter has been deleted then // just send exit events to anything we are tracking. // Afterwards, exit. if (newEnterTarget == null || currentPointerData.pointerEnter == null) { for (var i = 0; i < currentPointerData.hovered.Count; ++i) { EventExecutor.Execute(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerExitHandler); } currentPointerData.hovered.Clear(); if (newEnterTarget == null) { currentPointerData.pointerEnter = newEnterTarget; return; } } // If we have not changed hover target. if (newEnterTarget && currentPointerData.pointerEnter == newEnterTarget) { return; } GameObject commonRoot = ModuleController.FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget); // We already an entered object from last time. if (currentPointerData.pointerEnter != null) { // Send exit handler call to all elements in the chain // until we reach the new target, or null! Transform t = currentPointerData.pointerEnter.transform; while (t != null) { // If we reach the common root break out! if (commonRoot != null && commonRoot.transform == t) { break; } EventExecutor.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerExitHandler); currentPointerData.hovered.Remove(t.gameObject); t = t.parent; } } // Now issue the enter call up to but not including the common root. currentPointerData.pointerEnter = newEnterTarget; if (newEnterTarget != null) { Transform t = newEnterTarget.transform; while (t != null && t.gameObject != commonRoot) { EventExecutor.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerEnterHandler); currentPointerData.hovered.Add(t.gameObject); t = t.parent; } } }
public void OnPointerUp(PointerEventData e) { _isTouching = false; normalizedPoint = Vector3.zero; handle.anchoredPosition = Vector3.zero; }
public virtual void OnPointerDown(PointerEventData ped) { OnDrag(ped); }
public void OnBeginDrag(PointerEventData eventData) { itemBeingDragged = gameObject; GameState.gameChangedSinceLoad = true; objects = GameObject.FindGameObjectsWithTag("shape"); }
public virtual void OnPointerUp(PointerEventData ped) { inputVector = Vector3.zero; joystickImg.rectTransform.anchoredPosition = Vector3.zero; }
private void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released) { var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject; // PointerDown notification if (pressed) { pointerEvent.eligibleForClick = true; pointerEvent.delta = Vector2.zero; pointerEvent.dragging = false; pointerEvent.useDragThreshold = true; pointerEvent.pressPosition = pointerEvent.position; pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast; DeselectIfSelectionChanged(currentOverGo, pointerEvent); if (pointerEvent.pointerEnter != currentOverGo) { // send a pointer enter to the touched element if it isn't the one to select... HandlePointerExitAndEnter(pointerEvent, currentOverGo); pointerEvent.pointerEnter = currentOverGo; } // search for the control that will receive the press // if we can't find a press handler set the press // handler to be what would receive a click. var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler); // didnt find a press handler... search for a click handler if (newPressed == null) newPressed = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo); // Debug.Log("Pressed: " + newPressed); float time = Time.unscaledTime; if (newPressed == pointerEvent.lastPress) { var diffTime = time - pointerEvent.clickTime; if (diffTime < 0.3f) ++pointerEvent.clickCount; else pointerEvent.clickCount = 1; pointerEvent.clickTime = time; } else { pointerEvent.clickCount = 1; } pointerEvent.pointerPress = newPressed; pointerEvent.rawPointerPress = currentOverGo; pointerEvent.clickTime = time; // Save the drag handler as well pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>(currentOverGo); if (pointerEvent.pointerDrag != null) ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag); } // PointerUp notification if (released) { // Debug.Log("Executing pressup on: " + pointer.pointerPress); ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler); // Debug.Log("KeyCode: " + pointer.eventData.keyCode); // see if we mouse up on the same element that we clicked on... var pointerUpHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo); // PointerClick and Drop events if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick) { ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler); } else if (pointerEvent.pointerDrag != null && pointerEvent.dragging) { ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler); } pointerEvent.eligibleForClick = false; pointerEvent.pointerPress = null; pointerEvent.rawPointerPress = null; if (pointerEvent.pointerDrag != null && pointerEvent.dragging) ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler); pointerEvent.dragging = false; pointerEvent.pointerDrag = null; if (pointerEvent.pointerDrag != null) ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler); pointerEvent.pointerDrag = null; // send exit events as we need to simulate this on touch up on touch device ExecuteEvents.ExecuteHierarchy(pointerEvent.pointerEnter, pointerEvent, ExecuteEvents.pointerExitHandler); pointerEvent.pointerEnter = null; } }
public void OnPointerDown(PointerEventData eventData) { parent.SetAsLastSibling(); RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)transform.parent, eventData.position, eventData.pressEventCamera, out mouseOffset); }
protected void RemovePointerData(PointerEventData data) { m_PointerData.Remove(data.pointerId); }
public virtual void OnPointerUp(PointerEventData data) { InputDirection = Vector3.zero; xHandlerAnchor = Vector3.zero; }
public void SetButtonState(PointerEventData.InputButton button, PointerEventData.FramePressState stateForMouseButton, PointerEventData data) { var toModify = GetButtonState(button); toModify.eventData.buttonState = stateForMouseButton; toModify.eventData.buttonData = data; }
public void OnPointerClick(PointerEventData eventData) { player.ToggleInvenotry(); Toggel(); }
void OnPointerEnter(PointerEventData eventData) { TrySetResult(onPointerEnter, onPointerEnters, eventData); }
public void OnPointerDown(PointerEventData data) { startPosition = data.position; }
public void OnDrag(PointerEventData eventData) { transform.position = Input.mousePosition; }
public void OnPointerDown(PointerEventData pointerEventData) { StartCoroutine(RotateContinuously()); }
public void OnBeginDrag(PointerEventData eventData) { switch (GetComponentInParent <TeamSelect>().Type) { case PanelTeamType.Managment: switch (StaticValues.Team[index - 1].CharacterStatus) { case CharacterStatus.ready: empty = false; HoldChar = Instantiate(Icon, GetComponentInParent <Canvas>().transform, true); HoldChar.transform.position = Icon.transform.position; if (HoldChar.GetComponent <RectTransform>() == null) { HoldChar.AddComponent <RectTransform>(); } HoldChar.AddComponent <CanvasGroup>(); rectTransform = HoldChar.GetComponent <RectTransform>(); canvasGroup = HoldChar.GetComponent <CanvasGroup>(); canvasGroup.blocksRaycasts = false; if (this.gameObject.GetComponent <CanvasGroup>() == null) { this.gameObject.AddComponent <CanvasGroup>(); } this.gameObject.GetComponent <CanvasGroup>().alpha = 0.6f; break; default: empty = true; break; } break; case PanelTeamType.Select_To_Mission: if (GetComponentInParent <TeamPanel>().CharCard.activeSelf) { empty = true; } else { var group = GetComponentInParent <TravelSelect_Panel>().selectedGroup; switch (group.type) { case ForceTravel.TravelType.Camp: switch (StaticValues.Team[index].CharacterStatus) { case CharacterStatus.ready: empty = false; HoldChar = Instantiate(Icon, GetComponentInParent <Canvas>().transform, true); HoldChar.transform.position = Icon.transform.position; if (HoldChar.GetComponent <RectTransform>() == null) { HoldChar.AddComponent <RectTransform>(); } HoldChar.AddComponent <CanvasGroup>(); rectTransform = HoldChar.GetComponent <RectTransform>(); canvasGroup = HoldChar.GetComponent <CanvasGroup>(); canvasGroup.blocksRaycasts = false; if (this.gameObject.GetComponent <CanvasGroup>() == null) { this.gameObject.AddComponent <CanvasGroup>(); } this.gameObject.GetComponent <CanvasGroup>().alpha = 0.6f; break; default: empty = true; break; } break; case ForceTravel.TravelType.Village: switch (StaticValues.Cities[((VillageMapPointController)StaticValues.points[group.id]).id].Team_in_city[index].CharacterStatus) { case CharacterStatus.ready: empty = false; HoldChar = Instantiate(Icon, GetComponentInParent <Canvas>().transform, true); HoldChar.transform.position = Icon.transform.position; if (HoldChar.GetComponent <RectTransform>() == null) { HoldChar.AddComponent <RectTransform>(); } HoldChar.AddComponent <CanvasGroup>(); rectTransform = HoldChar.GetComponent <RectTransform>(); canvasGroup = HoldChar.GetComponent <CanvasGroup>(); canvasGroup.blocksRaycasts = false; if (this.gameObject.GetComponent <CanvasGroup>() == null) { this.gameObject.AddComponent <CanvasGroup>(); } this.gameObject.GetComponent <CanvasGroup>().alpha = 0.6f; break; default: empty = true; break; } break; } } break; default: empty = true; break; } }
public void OnPointerEnter(PointerEventData pointerEventData) { // Actually not really needed // but not sure if maybe required for having OnPointerExit work }
public void OnDrag(PointerEventData e) { pointerEventData = e; }
public void OnPointerExit(PointerEventData pointerEventData) { StopAllCoroutines(); }
public void OnDrag(PointerEventData eventData)//拖拽过程中 { // transform.position = canvasCamera.ScreenToWorldPoint(Input.mousePosition);//鼠标左键按住拖拽的时候,物体跟着鼠标移动 //transform.position = Input.mousePosition;//鼠标左键按住拖拽物体的时候不显示物体 }
public void OnPointerExit(PointerEventData eventData) => ToolTipSystem.Instance.HideToolTip(ability: true);
public void OnPointerDown(PointerEventData data) { _isDown = true; }
protected bool GetPointerData(int id, out PointerEventData data, bool create) { if (!m_PointerData.TryGetValue(id, out data) && create) { data = new PointerEventData(eventSystem) { pointerId = id, }; m_PointerData.Add(id, data); return true; } return false; }
public void OnDrag(PointerEventData eventData) { newPos = Input.mousePosition; newPos = grid.getGridPosition(newPos); rectTrans.position = newPos; }
protected virtual void ProcessDrag(PointerEventData pointerEvent) { bool moving = pointerEvent.IsPointerMoving(); if (moving && pointerEvent.pointerDrag != null && !pointerEvent.dragging && ShouldStartDrag(pointerEvent.pressPosition, pointerEvent.position, eventSystem.pixelDragThreshold, pointerEvent.useDragThreshold)) { ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.beginDragHandler); pointerEvent.dragging = true; } // Drag notification if (pointerEvent.dragging && moving && pointerEvent.pointerDrag != null) { // Before doing drag we should cancel any pointer down state // And clear selection! if (pointerEvent.pointerPress != pointerEvent.pointerDrag) { ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler); pointerEvent.eligibleForClick = false; pointerEvent.pointerPress = null; pointerEvent.rawPointerPress = null; } ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.dragHandler); } }
private void ProcessInteraction(PointerEventData pointer, bool pressed, bool released) { var currentOverGo = pointer.pointerCurrentRaycast.gameObject; objectUnderAimer = ExecuteEvents.GetEventHandler<ISubmitHandler>(currentOverGo);//we only want objects that we can submit on. if (pressed) { pointer.eligibleForClick = true; pointer.delta = Vector2.zero; pointer.pressPosition = pointer.position; pointer.pointerPressRaycast = pointer.pointerCurrentRaycast; // search for the control that will receive the press // if we can't find a press handler set the press // handler to be what would receive a click. var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointer, ExecuteEvents.submitHandler); // didnt find a press handler... search for a click handler if (newPressed == null) { newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointer, ExecuteEvents.pointerDownHandler); if (newPressed == null) newPressed = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo); } else { pointer.eligibleForClick = false; } if (newPressed != pointer.pointerPress) { pointer.pointerPress = newPressed; pointer.rawPointerPress = currentOverGo; pointer.clickCount = 0; } // Save the drag handler as well pointer.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>(currentOverGo); if (pointer.pointerDrag != null) ExecuteEvents.Execute<IBeginDragHandler>(pointer.pointerDrag, pointer, ExecuteEvents.beginDragHandler); } if (released) { //Debug.Log("Executing pressup on: " + pointer.pointerPress); ExecuteEvents.Execute(pointer.pointerPress, pointer, ExecuteEvents.pointerUpHandler); //Debug.Log("KeyCode: " + pointer.eventData.keyCode); // see if we mouse up on the same element that we clicked on... var pointerUpHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo); // PointerClick if (pointer.pointerPress == pointerUpHandler && pointer.eligibleForClick) { float time = Time.unscaledTime; if (time - pointer.clickTime < 0.3f) ++pointer.clickCount; else pointer.clickCount = 1; pointer.clickTime = time; ExecuteEvents.Execute(pointer.pointerPress, pointer, ExecuteEvents.pointerClickHandler); } else if (pointer.pointerDrag != null) { ExecuteEvents.ExecuteHierarchy(currentOverGo, pointer, ExecuteEvents.dropHandler); } pointer.eligibleForClick = false; pointer.pointerPress = null; pointer.rawPointerPress = null; if (pointer.pointerDrag != null) ExecuteEvents.Execute(pointer.pointerDrag, pointer, ExecuteEvents.endDragHandler); pointer.pointerDrag = null; } }
/// <summary> /// Cast a ray to test if Input.mousePosition is over any UI object in EventSystem.current. This is a replacement /// for IsPointerOverGameObject() which does not work on Android in 4.6.0f3 /// </summary> public static bool IsPointerOverUIObject() { bool hit = false; // Referencing this code for GraphicRaycaster https://gist.github.com/stramit/ead7ca1f432f3c0f181f // the ray cast appears to require only eventData.position. PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current); eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y); List<RaycastResult> results = new List<RaycastResult>(); EventSystem.current.RaycastAll(eventDataCurrentPosition, results); foreach(RaycastResult i in results) { if(i.gameObject.name == "CamraControl") { hit = false; }else { hit = true; } } return hit; }