public void OnPointerEnteredCanvas(DynamicPanelsCanvas canvas, PointerEventData pointer)
        {
            if (draggedPanel != null && pointer.pointerDrag != null)
            {
                PanelHeader header = pointer.pointerDrag.GetComponent <PanelHeader>();
                if (header != null)
                {
                    if (header.Panel == draggedPanel && header.Panel.RectTransform.parent != canvas.RectTransform)
                    {
                        previewPanelCanvas = canvas;

                        header.Panel.RectTransform.SetParent(canvas.RectTransform, false);
                        header.Panel.RectTransform.SetAsLastSibling();
                    }
                }
                else
                {
                    PanelTab tab = pointer.pointerDrag.GetComponent <PanelTab>();
                    if (tab != null)
                    {
                        if (tab.Panel == draggedPanel && previewPanel.parent != canvas.RectTransform)
                        {
                            previewPanelCanvas = canvas;

                            previewPanel.SetParent(canvas.RectTransform, false);
                            previewPanel.SetAsLastSibling();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void OnPanelTranslate(PanelHeader panelHeader, PointerEventData draggingPointer)
        {
            if (draggedPanel == panelHeader.Panel)
            {
                Vector2 touchPos;
                RectTransformUtility.ScreenPointToLocalPointInRectangle(draggedPanel.RectTransform, draggingPointer.position, previewPanelCanvas.Internal.worldCamera, out touchPos);

                draggedPanel.RectTransform.anchoredPosition += touchPos - panelHeader.InitialTouchPos;
            }
        }