Пример #1
0
        void _scheduleDragFromEditorReleaseCheck()
        {
            DragAndDrop.AcceptDrag();

            var lastMouseEvent = new List <PointerEvent>();

            foreach (int deviceId in _lastMouseEvent.Keys)
            {
                var _deviceId   = deviceId;
                var deviceEvent = _lastMouseEvent[_deviceId];

                //only process PointerEditorDragEvents
                if (!(deviceEvent is PointerDragFromEditorEnterEvent ||
                      deviceEvent is PointerDragFromEditorHoverEvent ||
                      deviceEvent is PointerDragFromEditorExitEvent))
                {
                    continue;
                }

                lastMouseEvent.Add(_lastMouseEvent[_deviceId]);
                SchedulerBinding.instance.addPostFrameCallback(_ => {
                    foreach (var lastEvent in lastMouseEvent)
                    {
                        EditorMouseTrackerAnnotation hit = annotationFinder(lastEvent.position);

                        if (hit == null)
                        {
                            foreach (_EditorTrackedAnnotation trackedAnnotation in _trackedAnnotations.Values)
                            {
                                if (trackedAnnotation.activeDevices.Contains(_deviceId))
                                {
                                    trackedAnnotation.activeDevices.Remove(_deviceId);
                                }
                            }

                            return;
                        }

                        _EditorTrackedAnnotation hitAnnotation = _findAnnotation(hit);

                        // release
                        if (hitAnnotation.activeDevices.Contains(_deviceId))
                        {
                            if (hitAnnotation.annotation?.onDragFromEditorRelease != null)
                            {
                                hitAnnotation.annotation.onDragFromEditorRelease(
                                    PointerDragFromEditorReleaseEvent
                                    .fromDragFromEditorEvent(
                                        lastEvent, DragAndDrop.objectReferences, DragAndDrop.paths));
                            }

                            hitAnnotation.activeDevices.Remove(_deviceId);
                        }
                    }
                });
            }

            SchedulerBinding.instance.scheduleFrame();
        }
Пример #2
0
        void _scheduleDragFromEditorReleaseCheck()
        {
            DragAndDrop.AcceptDrag();

            var lastMouseEvent = new List <PointerEvent>();

            foreach (int deviceId in this._lastMouseEvent.Keys)
            {
                var _deviceId = deviceId;
                lastMouseEvent.Add(this._lastMouseEvent[_deviceId]);
                SchedulerBinding.instance.addPostFrameCallback(_ => {
                    foreach (var lastEvent in lastMouseEvent)
                    {
                        MouseTrackerAnnotation hit = this.annotationFinder(lastEvent.position);

                        if (hit == null)
                        {
                            foreach (_TrackedAnnotation trackedAnnotation in this._trackedAnnotations.Values)
                            {
                                if (trackedAnnotation.activeDevices.Contains(_deviceId))
                                {
                                    trackedAnnotation.activeDevices.Remove(_deviceId);
                                }
                            }

                            return;
                        }

                        _TrackedAnnotation hitAnnotation = this._findAnnotation(hit);

                        // release
                        if (hitAnnotation.activeDevices.Contains(_deviceId))
                        {
                            if (hitAnnotation.annotation?.onDragFromEditorRelease != null)
                            {
                                hitAnnotation.annotation.onDragFromEditorRelease(
                                    PointerDragFromEditorReleaseEvent
                                    .fromDragFromEditorEvent(
                                        lastEvent, DragAndDrop.objectReferences));
                            }

                            hitAnnotation.activeDevices.Remove(_deviceId);
                        }
                    }
                });
            }

            SchedulerBinding.instance.scheduleFrame();
        }