/// <summary>
        /// Triggers events and queries for changes in drag and drop operations. Should be called every frame.
        /// </summary>
        public void Update()
        {
            Vector2I currentWindowPos = parentWindow.ScreenToWindowPos(Input.PointerPosition);

            if (triggerStartLocalDrag)
            {
                isLocalDragInProgress = true;
                triggerStartLocalDrag = false;

                if (OnStart != null)
                {
                    OnStart(currentWindowPos);
                }
            }

            if (triggerEndLocalDrag)
            {
                triggerEndLocalDrag = false;

                if (OnEnd != null)
                {
                    OnEnd(currentWindowPos);
                }
            }

            if (isOSDragActive)
            {
                return;
            }

            bool externalDragInProgress = DragDrop.DragInProgress && DragDrop.Type == DragDropType.SceneObject;

            if (isLocalDragInProgress || externalDragInProgress)
            {
                if (lastDragWindowPos != currentWindowPos)
                {
                    if (!isDragInBounds)
                    {
                        if (Bounds.Contains(currentWindowPos))
                        {
                            isDragInBounds = true;
                            if (OnEnter != null)
                            {
                                OnEnter(currentWindowPos);
                            }
                        }
                    }

                    if (OnDrag != null)
                    {
                        OnDrag(currentWindowPos);
                    }

                    if (isDragInBounds)
                    {
                        if (!Bounds.Contains(currentWindowPos))
                        {
                            isDragInBounds = false;
                            if (OnLeave != null)
                            {
                                OnLeave();
                            }
                        }
                    }

                    lastDragWindowPos = currentWindowPos;
                }
            }

            if (DragDrop.DropInProgress && Bounds.Contains(currentWindowPos))
            {
                if (DragDrop.Type == DragDropType.Resource)
                {
                    if (OnDropResource != null)
                    {
                        ResourceDragDropData resourceDragDrop = (ResourceDragDropData)DragDrop.Data;
                        OnDropResource(currentWindowPos, resourceDragDrop.Paths);
                    }
                }
                else if (DragDrop.Type == DragDropType.SceneObject)
                {
                    if (OnDropSceneObject != null)
                    {
                        SceneObjectDragDropData sceneDragDrop = (SceneObjectDragDropData)DragDrop.Data;
                        OnDropSceneObject(currentWindowPos, sceneDragDrop.Objects);
                    }
                }

                isDragInBounds = false;
            }
        }
Exemple #2
0
 private static extern void Internal_CreateInstance(SceneObjectDragDropData instance, SceneObject[] objects);