//////////////////////////////////////////////////////////////////////// // Private Methods //////////////////////////////////////////////////////////////////////// private void HandleOnObjectEntered(ZPointer p, GameObject objectEntered) { if (objectEntered.GetComponent <Draggable>() != null) { this._isDraggableIntersected = true; } }
protected void ProcessPointerEvent(ZPointer pointer) { for (int i = 0; i < pointer.ButtonCount; ++i) { ZPointerEventData eventData = this.GetEventData(pointer, i); // Process button press/release events. if (pointer.GetButtonDown(i)) { this.ProcessButtonPress(eventData); } if (pointer.GetButtonUp(i)) { this.ProcessButtonRelease(eventData); } // Process move/scroll events only for the primary button. if (eventData.button == PointerEventData.InputButton.Left) { this.ProcessMove(eventData); this.ProcessScroll(eventData); } // Process drag events. this.ProcessDrag(eventData); } }
private void HandleOnButtonReleased(ZPointer p, int i) { if (i == 0) { this._isDrawing = false; this._accumulatedDelta = 0.0f; } }
//////////////////////////////////////////////////////////////////////// // Protected Methods //////////////////////////////////////////////////////////////////////// protected void ProcessPointers() { IList <ZPointer> pointers = ZPointer.GetInstances(); for (int i = 0; i < pointers.Count; ++i) { this.ProcessPointerEvent(pointers[i]); } }
public override Plane GetDragPlane(ZPointer pointer) { if (PlaneQuadTransform != null) { return(new Plane( PlaneQuadTransform.forward, PlaneQuadTransform.position)); } return(base.GetDragPlane(pointer)); }
private void HandleOnButtonPressed(ZPointer p, int i) { if (!this._isDraggableIntersected && i == 0) { this._isDrawing = true; this._pointList.Clear(); this._pointList.Add(this.Pointer.EndPointWorldPose.position); this._lineRenderer.positionCount = this._pointList.Count; this._lineRenderer.SetPositions(this._pointList.ToArray()); } }
//////////////////////////////////////////////////////////////////////// // Public Methods //////////////////////////////////////////////////////////////////////// public override void Process(ZPointer pointer, Vector3 worldScale) { base.Process(pointer, worldScale); this.transform.localPosition = Vector3.forward * pointer.HitInfo.distance; if (pointer.HitInfo.worldNormal != Vector3.zero) { this.transform.rotation = Quaternion.LookRotation( Vector3.zero - pointer.HitInfo.worldNormal, Vector3.up); } }
//////////////////////////////////////////////////////////////////////// // Public Methods //////////////////////////////////////////////////////////////////////// public override ZPointer.DragPolicy GetDragPolicy(ZPointer pointer) { if (pointer is ZMouse) { return(ZPointer.DragPolicy.LockToScreenAlignedPlane); } if (pointer is ZStylus) { return(ZPointer.DragPolicy.LockHitPosition); } return(base.GetDragPolicy(pointer)); }
protected ZPointerEventData GetEventData(ZPointer pointer, int buttonId) { int id = pointer.Id + buttonId; RaycastResult hitInfo = pointer.HitInfo; // Attempt to retrieve the pointer event data. If it doesn't exist, // create it. ZPointerEventData eventData = null; if (!this._eventDataCache.TryGetValue(id, out eventData)) { eventData = new ZPointerEventData(this.eventSystem); eventData.position = hitInfo.screenPosition; this._eventDataCache.Add(id, eventData); } // Reset the pointer event data before populating it with latest // information from the pointer. eventData.Reset(); eventData.Pointer = pointer; eventData.ButtonId = buttonId; eventData.IsUIObject = (hitInfo.gameObject?.GetComponent <RectTransform>() != null); eventData.Delta3D = hitInfo.worldPosition - eventData.pointerCurrentRaycast.worldPosition; eventData.button = pointer.GetButtonMapping(buttonId); eventData.delta = hitInfo.screenPosition - eventData.position; eventData.position = hitInfo.screenPosition; eventData.scrollDelta = pointer.ScrollDelta; eventData.pointerCurrentRaycast = hitInfo; return(eventData); }
//////////////////////////////////////////////////////////////////////// // Public Methods //////////////////////////////////////////////////////////////////////// public override ZPointer.DragPolicy GetDragPolicy(ZPointer pointer) { return(ZPointer.DragPolicy.LockToCustomPlane); }
private void HandleOnObjectExited(ZPointer p, GameObject objectEntered) { this._isDraggableIntersected = false; }
private bool IsMousePointerActive() { IList <ZPointer> pointers = ZPointer.GetInstances(); return(pointers.Any(p => p is ZMouse)); }