void Update() { graphScene.Update(1); // Mouse Input Action. if (Input.GetMouseButton(0)) { Ray mouseRay = GenerateMouseRay(); RaycastHit hit; if (Physics.Raycast(mouseRay.origin, mouseRay.direction, out hit)) { if (hit.collider.tag == "Node" && SelectedObject == null) { SelectedObject = hit.collider.gameObject; ResetLineColor(); Selected = false; } } UpdateTypePos(); } if (SelectedObject) { Vector3 newPos = cam.ScreenToWorldPoint(Input.mousePosition); SelectedObject.transform.position = new Vector3(newPos.x, newPos.y, SelectedObject.transform.position.z); NeoUnity.Node sn = SelectedObject.GetComponent <NeoUnity.Node>(); SelectedText.text = "OBJ: " + sn.gameObject.name; SelectedTitle.text = sn.Title; SelectedContent.text = sn.Content; if (!Selected) { ChangeLineColor(SelectedObject); Selected = true; } } if (Input.GetMouseButtonUp(0)) { SelectedText.text = "DRAG A NODE"; SelectedTitle.text = ""; SelectedContent.text = ""; ResetLineColor(); Selected = false; SelectedObject = null; } if (Input.GetMouseButton(1)) { float x = -Input.GetAxis("Mouse X"); float y = -Input.GetAxis("Mouse Y"); cam.transform.position += new Vector3(x, y) * (Zoom / MaxZoom) * PanMult; } Zoom = Mathf.Clamp(Zoom - (Input.GetAxis("Mouse ScrollWheel") * (Zoom / MaxZoom) * ZoomSpeed), MinZoom, MaxZoom); cam.orthographicSize = Zoom; }
void Update() { if (_leftMenuMoving) { RectTransform rt = LeftMenuPanel.GetComponent <RectTransform>(); if (_leftMenu) { if (rt.position.x < -220) { _leftMenuMoving = false; _leftMenu = false; rt.position = new Vector3(-220, Screen.height, 0); } else { rt.position -= new Vector3(_tSpeed, 0, 0) * Time.deltaTime; } } else { if (rt.position.x >= 0) { _leftMenuMoving = false; _leftMenu = true; rt.position = new Vector3(0, Screen.height, 0); } else { rt.position += new Vector3(_tSpeed, 0, 0) * Time.deltaTime; } } } if (Input.GetMouseButton(0)) { Ray r = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D rh = Physics2D.GetRayIntersection(r, Mathf.Infinity); if (rh) { if (rh.collider.tag == "Node") { SelectedObject = rh.collider.gameObject; if (!_nodeCard) { _nodeCard = Instantiate(NodeCardPrefab); _nodeCard.transform.parent = SelectedObject.transform; _nodeCard.transform.localPosition = new Vector3(1, 1); NeoUnity.Node n = SelectedObject.GetComponent <NeoUnity.Node>(); _nodeCard.transform.GetChild(0).GetChild(1).GetChild(0).GetComponent <Text>().text = "Name: " + n.Name + "\nData: " + n.Data; } if (_nodeCard.transform.parent != SelectedObject.transform) { DestroyImmediate(_nodeCard); } } } else { DestroyImmediate(_nodeCard); } } if (SelectedObject) { SelectedObject.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10)); } if (Input.GetMouseButtonUp(0)) { SelectedObject = null; } if (Input.GetMouseButton(1)) { float x = -Input.GetAxis("Mouse X"); float y = -Input.GetAxis("Mouse Y"); this.transform.position += new Vector3(x, y) * (Zoom / MaxZoom) * PanMult; } Zoom = Mathf.Clamp(Zoom - (Input.GetAxis("Mouse ScrollWheel") * (Zoom / MaxZoom) * ZoomSpeed), MinZoom, MaxZoom); Camera.main.orthographicSize = Zoom; }