void OnMouseDrag() { if (!enabled) { return; } Vector3 pos = Input.mousePosition; pos.z = -cam.transform.position.z; pos = cam.ScreenToWorldPoint(pos); float nx = Mathf.Floor(pos.x) + 0.5f; float ny = Mathf.Floor(pos.y) + 0.5f; Debug.Log("Attempting new position of " + nx + "," + ny); if (tile == null || tile.IsPositionValid(new Vector2(nx, ny))) { xform.position = new Vector3(nx, ny, xform.position.z); } }