void Update() { if (PlayManager.GetIsPlay() || !isSelected) { lineRenderer.enabled = false; for (int i = 0; i < nodes.Length; i++) { nodes[i].SetActive(false); } } else { lineRenderer.enabled = true; for (int i = 0; i < nodes.Length; i++) { nodes[i].SetActive(true); } } isSelected = gameObject.name.Equals(draw.GetLayer()); if (Input.GetMouseButtonDown(0) && isSelected) { mousePositionBuffer = MouseUtilities.WorldSpace(cam); } if (Input.GetMouseButton(0) && isSelected) { Vector3 positionChange = MouseUtilities.WorldSpace(cam) - mousePositionBuffer; for (int i = 0; i < nodes.Length; i++) { Vector3 normalizedPosition = new Vector3(nodes[i].transform.position.x, nodes[i].transform.position.y, 0); if ((Vector3.Distance(MouseUtilities.WorldSpace(cam), normalizedPosition) < 0.5f && currentlyDragged == -1) || currentlyDragged == i) { nodes[i].transform.position += positionChange; lineRenderer.SetPosition(i, nodes[i].transform.position + Vector3.forward); currentlyDragged = i; break; } } mousePositionBuffer = MouseUtilities.WorldSpace(cam); } if (Input.GetMouseButtonUp(0) && isSelected) { for (int i = 0; i < nodes.Length; i++) { Vector3 pos = nodes[i].transform.position; nodes[i].transform.position = new Vector3(Mathf.Round(pos.x), Mathf.Round(pos.y), pos.z); lineRenderer.SetPosition(i, nodes[i].transform.position + Vector3.forward); } currentlyDragged = -1; } }
void Update() { if (!paletteMenuManager.IsPaletteMenuActive()) { cam.orthographicSize *= 1.0f - Input.GetAxis("Mouse ScrollWheel") * scrollSensitivity; if (cam.orthographicSize > maxSize) { cam.orthographicSize = maxSize; } if (cam.orthographicSize < minSize) { cam.orthographicSize = minSize; } if (Input.GetMouseButton(2)) { transform.position += panStart - MouseUtilities.WorldSpace(cam); } panStart = MouseUtilities.WorldSpace(cam); } }