Пример #1
0
        public void Deselect()
        {
            if (SelectedVisualisation != null)
            {
                SelectedVisualisation.Deselect();
                SelectedVisualisation = null;
            }

            NodeInfoDialog.gameObject.SetActive(false);
        }
Пример #2
0
        public void Select(Visualisation obj)
        {
            obj.Select();
            SelectedVisualisation = obj;

            if (obj is NodeVisualisation)
            {
                NodeInfoDialog.GraphEditor = this;
                NodeInfoDialog.gameObject.SetActive(true);
                NodeInfoDialog.SetNode((obj as NodeVisualisation).Component);
            }
        }
Пример #3
0
        private void NodeDraggingAction()
        {
            Vector3 potentialNewPosition = UnityEngine.Input.mousePosition + StartingDragOffset;

            if (v is ComponentNameVisualisation)
            {
                if (((v as ComponentNameVisualisation).Component.Visualisation.transform.position - potentialNewPosition).magnitude > 0.5f)
                {
                    v = (v as ComponentNameVisualisation).Component.Visualisation;
                }
            }

            if (v is NodeVisualisation)
            {
                v.transform.position = potentialNewPosition;
                UpdateEdges();
            }
        }
Пример #4
0
        void Update()
        {
            if (isDragging)
            {
                draggingAction.Invoke();

                if (UnityEngine.Input.GetMouseButtonUp(0))
                {
                    EndDragging();
                }
            }
            else
            {
                if (UnityEngine.Input.GetMouseButtonDown(0))
                {
                    bool foundViewport = false;
                    Raycast();

                    // Initial pass to check for forbidden areas
                    for (int i = 0; i < results.Count; i++)
                    {
                        if (results[i].gameObject.name == "NodeInfoDialog")
                        {
                            return;
                        }
                    }

                    for (int i = 0; i < results.Count; i++)
                    {
                        v = results[i].gameObject.GetComponent <Visualisation>();
                        if (v != null)
                        {
                            if (v is PortVisualisation)
                            {
                                PortStartDraggingAction();
                                draggingAction    = PortDraggingAction;
                                endDraggingAction = PortEndDraggingAction;

                                StartDragging();
                                break;
                            }
                            else if (v is EdgeVisualisation)
                            {
                                EdgeStartDraggingAction();
                                draggingAction    = EdgeDraggingAction;
                                endDraggingAction = EdgeEndDraggingAction;

                                StartDragging();
                                break;
                            }
                            else if (v is ComponentNameVisualisation)
                            {
                                NodeStartDraggingAction();
                                draggingAction    = NodeDraggingAction;
                                endDraggingAction = NodeEndDraggingAction;

                                StartDragging();
                                break;
                            }
                            else if (v is NodeVisualisation)
                            {
                                NodeStartDraggingAction();
                                draggingAction    = NodeDraggingAction;
                                endDraggingAction = NodeEndDraggingAction;

                                StartDragging();
                                break;
                            }
                        }
                        else if (results[i].gameObject.name == "Viewport")
                        {
                            foundViewport = true;
                        }
                    }

                    if (foundViewport)
                    {
                        Deselect();
                    }
                }
            }
        }