// Update is called once per frame void Update() { bool camMove = DebugManager.Check(debugMessage); if (Input.GetKey(KeyCode.Space) && camMove) { Scroll(); } if (Input.GetMouseButtonDown(0) && camMove) { print("buttonDown"); Moving = true; Vector2 camScreenPos = new Vector2(Screen.width / 2, Screen.height / 2); Vector2 mousePos = Input.mousePosition; // if (oldMousepos == null) camStart = cam.transform.position; Vector2 worldMouse = cam.ScreenToWorldPoint(mousePos); startMousePos = Input.mousePosition; } else if (Input.GetMouseButton(0) && camMove) { // print("moving"); Move(); } else if (Input.GetMouseButtonUp(0) && camMove) { // print("Release"); Moving = false; } }
void DebugConnections() { if (!DebugManager.Check(debugMessage)) { return; } Gizmos.color = Color.magenta; if (rooms.Length > 0) { for (int i = 0; i < rooms.GetLength(0); i++) { for (int j = 0; j < rooms.GetLength(1); j++) { Vector2 pos = rooms[i, j].transform.position; foreach (Room item in (rooms[i, j] as Room).Connections) { Gizmos.DrawLine(pos, item.transform.position); } } } // Gizmos.color = Color.blue; Gizmos.DrawSphere(startRoom.transform.position, 0.3f); Gizmos.DrawSphere(endRoom.transform.position, 0.3f); } }
/// <summary> /// Callback to draw gizmos that are pickable and always drawn. /// </summary> void OnDrawGizmos() { DrawSize(); // QuadTree.Draw(quadTree); if (!DebugManager.Check(colorDebugMessage)) { return; } List <Vector2Int> pointsToRender = new List <Vector2Int>(); cam = Camera.main; Vector2 camPos = cam.transform.position; float height = cam.orthographicSize; float width = cam.aspect * height; Vector2 camSize = new Vector2(width, height); if (vectors.Length != 0) { for (int i = 0; i < vectors.GetLength(0); i++) { for (int j = 0; j < vectors.GetLength(1); j++) { if (CheckBoundary((Vector2)vectors[i, j], camPos, camSize)) { pointsToRender.Add(new Vector2Int(i, j)); } } } } print(HighestWeight); foreach (var point in pointsToRender) { float colorval = 1 - (float)Weights[point.x, point.y] / (float)HighestWeight; // colorval = Mathf.Sin(colorval * 100); Gizmos.color = new Color(colorval, colorval, colorval); Gizmos.DrawCube(vectors[point.x, point.y], Vector3.one * 0.03f); } }
/// <summary> /// OnGUI is called for rendering and handling GUI events. /// This function can be called multiple times per frame (one call per event). /// </summary> void OnGUI() { if (DebugManager.Check(DebugMessage)) { List <Vector2Int> pointsToRender = new List <Vector2Int>(); cam = Camera.main; Vector2 camPos = cam.transform.position; float height = cam.orthographicSize; float width = cam.aspect * height; Vector2 camSize = new Vector2(width, height); for (int i = 0; i < vectors.GetLength(0); i++) { for (int j = 0; j < vectors.GetLength(1); j++) { if (CheckBoundary((Vector2)vectors[i, j], camPos, camSize)) { pointsToRender.Add(new Vector2Int(i, j)); } } } print("points " + pointsToRender.Count); foreach (var point in pointsToRender) { // print(point); Vector2 pos = cam.WorldToScreenPoint(vectors[point.x, point.y]); pos.y = Screen.height - pos.y; pos.x += -12.5f; pos.y += -12.5f; Rect rect = new Rect(pos, Vector2.one * 25); var style = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter }; GUI.Label(rect, Weights[point.x, point.y].ToString(), style); } pointsToRender.Clear(); } if (DebugManager.Check(FlowPositions)) { List <Vector2Int> pointsToRender = new List <Vector2Int>(); cam = Camera.main; Vector2 camPos = cam.transform.position; float height = cam.orthographicSize; float width = cam.aspect * height; Vector2 camSize = new Vector2(width, height); for (int i = 0; i < vectors.GetLength(0); i++) { for (int j = 0; j < vectors.GetLength(1); j++) { if (CheckBoundary((Vector2)vectors[i, j], camPos, camSize)) { pointsToRender.Add(new Vector2Int(i, j)); } } } // print("points " + pointsToRender.Count); foreach (var point in pointsToRender) { // print(point); Vector2 pos = cam.WorldToScreenPoint(vectors[point.x, point.y]); pos.y = Screen.height - pos.y; pos.x += -12.5f; pos.y += -12.5f; Rect rect = new Rect(pos, Vector2.one * 40); var style = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter }; GUI.Label(rect, point.x.ToString() + " " + point.y.ToString(), style); } pointsToRender.Clear(); } }