private void AddSpaceAtMouse(Event e, Grid grid) { Vector2 pos = e.mousePosition; //Find mouse relative to scene view pos.y = SceneView.currentDrawingSceneView.camera.pixelHeight - pos.y; pos = SceneView.currentDrawingSceneView.camera.ScreenToWorldPoint(pos); //Fix cordinates to grid pos.x = Mathf.Min(grid.GridWidth - 1, Mathf.Max(0, (int)(pos.x))); pos.y = Mathf.Min(grid.GridHeight - 1, Mathf.Max(0, (int)(pos.y))); //AddTile grid.AddGridSpace((int)pos.x, (int)pos.y); }