private IEnumerator CreateReferenceItemCoroutine(PointerEventData eventData) { yield return(new WaitForSecondsRealtime(Hierarchy.DraggedReferenceHoldTime)); if (!BoundTransform.IsNull()) { RuntimeInspectorUtils.CreateDraggedReferenceItem(BoundTransform, eventData, Skin); } }
private IEnumerator CreateReferenceItemCoroutine(PointerEventData eventData) { float dragThreshold = EventSystem.current.pixelDragThreshold; yield return(new WaitForSecondsRealtime(holdTime)); if (m_reference && (eventData.position - eventData.pressPosition).sqrMagnitude < dragThreshold * dragThreshold) { RuntimeInspectorUtils.CreateDraggedReferenceItem(m_reference, eventData, draggedReferenceSkin, GetComponentInParent <Canvas>()); } }
private IEnumerator CreateReferenceItemCoroutine(PointerEventData eventData) { float dragThreshold = EventSystem.current.pixelDragThreshold; yield return(new WaitForSecondsRealtime(holdTime)); if (!m_reference.IsNull() && Vector2.Distance(eventData.position, eventData.pressPosition) < dragThreshold) { RuntimeInspectorUtils.CreateDraggedReferenceItem(m_reference, eventData, draggedReferenceSkin); } }
protected override void Update() { base.Update(); float time = Time.realtimeSinceStartup; if (!m_isInSearchMode) { if (time > nextHierarchyRefreshTime) { Refresh(); } } else if (time > nextSearchRefreshTime) { RefreshSearchResults(); } if (isListViewDirty) { RefreshListView(); } if (time > nextObjectNamesRefreshTime) { nextObjectNamesRefreshTime = time + m_objectNamesRefreshInterval; for (int i = sceneData.Count - 1; i >= 0; i--) { sceneData[i].ResetCachedNames(); } for (int i = searchSceneData.Count - 1; i >= 0; i--) { searchSceneData[i].ResetCachedNames(); } for (int i = drawers.Count - 1; i >= 0; i--) { if (drawers[i].gameObject.activeSelf) { drawers[i].RefreshName(); } } shouldRecalculateContentWidth = true; } if (m_showHorizontalScrollbar && shouldRecalculateContentWidth) { shouldRecalculateContentWidth = false; float preferredWidth = 0f; for (int i = drawers.Count - 1; i >= 0; i--) { if (drawers[i].gameObject.activeSelf) { float drawerWidth = drawers[i].PreferredWidth; if (drawerWidth > preferredWidth) { preferredWidth = drawerWidth; } } } float contentMinWidth = listView.ViewportWidth + scrollView.verticalScrollbarSpacing; if (preferredWidth > contentMinWidth) { scrollView.content.sizeDelta = new Vector2(preferredWidth - contentMinWidth, scrollView.content.sizeDelta.y); } else { scrollView.content.sizeDelta = new Vector2(0f, scrollView.content.sizeDelta.y); } } if (m_createDraggedReferenceOnHold && currentlyPressedDrawer && time > pressedDrawerDraggedReferenceCreateTime) { if (currentlyPressedDrawer.gameObject.activeSelf && currentlyPressedDrawer.Data.BoundTransform) { if (RuntimeInspectorUtils.CreateDraggedReferenceItem(currentlyPressedDrawer.Data.BoundTransform, pressedDrawerActivePointer, Skin, m_canvas)) { ((IPointerEnterHandler)dragDropListener).OnPointerEnter(pressedDrawerActivePointer); } } currentlyPressedDrawer = null; pressedDrawerActivePointer = null; } if (m_autoScrollSpeed != 0f) { scrollView.verticalNormalizedPosition = Mathf.Clamp01(scrollView.verticalNormalizedPosition + m_autoScrollSpeed * Time.unscaledDeltaTime / totalItemCount); } }
private void Update() { if (draggingPointer != null) { if (draggedReference.IsNull()) { draggingPointer = null; } else if (Input.GetMouseButtonUp(0)) { ExecuteEvents.Execute(draggedReference.gameObject, draggingPointer, ExecuteEvents.endDragHandler); if (EventSystem.current != null) { List <RaycastResult> hoveredUIElements = new List <RaycastResult>(); EventSystem.current.RaycastAll(draggingPointer, hoveredUIElements); int i = 0; while (i < hoveredUIElements.Count && ExecuteEvents.ExecuteHierarchy(hoveredUIElements[i].gameObject, draggingPointer, ExecuteEvents.dropHandler) == null) { i++; } } draggingPointer = null; } else { draggingPointer.position = Input.mousePosition; ExecuteEvents.Execute(draggedReference.gameObject, draggingPointer, ExecuteEvents.dragHandler); } } else { if (!pointerDown) { if (Input.GetMouseButtonDown(0) && EventSystem.current != null && !EventSystem.current.IsPointerOverGameObject()) { RaycastHit hit; if (Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out hit, raycastRange, interactableObjectsMask)) { hitObject = (ProcessRaycastHit != null) ? ProcessRaycastHit(hit) : hit.collider.gameObject; if (!hitObject.IsNull()) { pointerDown = true; pointerDownTime = Time.realtimeSinceStartup; pointerDownPos = Input.mousePosition; } } } } else { if (Input.GetMouseButton(0)) { if (((Vector2)Input.mousePosition - pointerDownPos).sqrMagnitude >= 100f) { pointerDown = false; } else if (Time.realtimeSinceStartup - pointerDownTime >= holdTime) { pointerDown = false; if (!hitObject.IsNull() && EventSystem.current != null) { draggingPointer = new PointerEventData(EventSystem.current) { pointerId = -111, pressPosition = Input.mousePosition, position = Input.mousePosition, button = PointerEventData.InputButton.Left }; draggedReference = RuntimeInspectorUtils.CreateDraggedReferenceItem(hitObject, draggingPointer, draggedReferenceSkin); if (draggedReference == null) { pointerDown = false; draggingPointer = null; } } } } else if (Input.GetMouseButtonUp(0)) { pointerDown = false; } } } }
private void Update() { #if !ENABLE_INPUT_SYSTEM || ENABLE_LEGACY_INPUT_MANAGER // On new Input System, DraggedReferenceItem's PointerEventData is tracked by DraggedReferenceItem itself, not this component if (draggingPointer != null) { if (!draggedReference || !draggedReference.gameObject.activeSelf) { draggingPointer = null; } else if (IsPointerHeld()) { draggingPointer.position = GetPointerPosition(); ExecuteEvents.Execute(draggedReference.gameObject, draggingPointer, ExecuteEvents.dragHandler); } else { ExecuteEvents.Execute(draggedReference.gameObject, draggingPointer, ExecuteEvents.endDragHandler); if (EventSystem.current != null) { hoveredUIElements.Clear(); EventSystem.current.RaycastAll(draggingPointer, hoveredUIElements); int i = 0; while (i < hoveredUIElements.Count && !ExecuteEvents.ExecuteHierarchy(hoveredUIElements[i].gameObject, draggingPointer, ExecuteEvents.dropHandler)) { i++; } } draggingPointer = null; } } else #endif { if (!pointerDown) { if (IsPointerDown() && EventSystem.current && !EventSystem.current.IsPointerOverGameObject()) { RaycastHit hit; if (Physics.Raycast(_camera.ScreenPointToRay(GetPointerPosition()), out hit, raycastRange, interactableObjectsMask)) { hitObject = (ProcessRaycastHit != null) ? ProcessRaycastHit(hit) : hit.collider.gameObject; if (hitObject) { pointerDown = true; pointerDownTime = Time.realtimeSinceStartup; pointerDownPos = GetPointerPosition(); } } } } else { if (IsPointerHeld()) { if ((GetPointerPosition() - pointerDownPos).sqrMagnitude >= 100f) { pointerDown = false; } else if (Time.realtimeSinceStartup - pointerDownTime >= holdTime) { pointerDown = false; if (hitObject && EventSystem.current) { draggingPointer = new PointerEventData(EventSystem.current) { #if !ENABLE_INPUT_SYSTEM || ENABLE_LEGACY_INPUT_MANAGER pointerId = Input.touchCount > 0 ? Input.GetTouch(0).fingerId : -1, #endif pressPosition = GetPointerPosition(), position = GetPointerPosition(), button = PointerEventData.InputButton.Left }; draggedReference = RuntimeInspectorUtils.CreateDraggedReferenceItem(hitObject, draggingPointer, draggedReferenceSkin, draggedReferenceCanvas); if (!draggedReference) { pointerDown = false; draggingPointer = null; } } } } else { pointerDown = false; } } } }