public void ProcessDragEvent(PointerRegion start, PointerRegion end) { int startId = nodes.IndexOf(start.gameObject); int endId = nodes.IndexOf(end.gameObject); if (startId >= 0 && endId >= 0) { Connection newConnection = new Connection(startId, endId); Connection existingConnection = connections.Find(c => c.Equals(newConnection)); if (existingConnection != null) { int existingConnectionIndex = connections.IndexOf(existingConnection); connections.RemoveAt(existingConnectionIndex); Destroy(instantiatedLines[existingConnectionIndex].gameObject); instantiatedLines.RemoveAt(existingConnectionIndex); } else { connections.Add(newConnection); SphericalLine newLine = Instantiate(linePrefab); newLine.start = start.region.SphereCoordinatesRef; newLine.finish = end.region.SphereCoordinatesRef; instantiatedLines.Add(newLine); onConnectionMade.Invoke(); } } }
public PointerRegion Translate(int x, int y) { PointerRegion pr = PointerRegion.None; if (inCenterArea(x, y)) { pr = PointerRegion.Center; } else if (inLeftArea(x, y)) { pr = PointerRegion.Left; } else if (inRightArea(x, y)) { pr = PointerRegion.Right; } else if (inUpArea(x, y)) { pr = PointerRegion.Up; } else if (inDownArea(x, y)) { pr = PointerRegion.Down; } else { pr = PointerRegion.None; } return(pr); }
private void Update() { PointerRegion.AllUpdateState(!IsInputBlocked); if (!IsInputBlocked) { PointerRegion regionBeingPointed = PointerRegion.RegionBeingPointed; if (Input.GetMouseButtonDown(0)) { startDragRegion = regionBeingPointed; } if (Input.GetMouseButtonUp(0)) { startDragRegion = null; } if (Input.GetMouseButton(0) && startDragRegion != regionBeingPointed && startDragRegion != null && regionBeingPointed != null) { onDragFromTo.Invoke(startDragRegion, regionBeingPointed); startDragRegion = regionBeingPointed; } } }