public void Deselect() { if (SelectedVisualisation != null) { SelectedVisualisation.Deselect(); SelectedVisualisation = null; } NodeInfoDialog.gameObject.SetActive(false); }
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); } }
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(); } }
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(); } } } }