// 格子坐标转为世界坐标 public Vector3 CellToWorld(Vector2 cell) { if (_mapGrid != null) { return(_mapGrid.CellToWorld(cell)); } return(Vector3.zero); }
void OnDrawGizmos() { if (_toggleErase.isOn) { return; } Vector3 start = _mapGrid.CellToWorld(_startCell); Vector3 end = _mapGrid.CellToWorld(_endCell); Gizmos.color = Color.gray; Gizmos.DrawSphere(start, 1); Gizmos.color = Color.black; Gizmos.DrawSphere(end, 1); if (_startCell.sqrMagnitude <= 0 || _endCell.sqrMagnitude <= 0) { return; } Gizmos.color = Color.blue; Gizmos.DrawSphere((end + start) / 2, 1); Color color = Color.gray; color.a = 0.7f; Gizmos.color = color; Gizmos.DrawCube((end + start) / 2, new Vector3(Mathf.Abs(end.x - start.x) + _mapGrid.GetCellWidth(), 1, Math.Abs(end.z - start.z) + _mapGrid.GetCellHeight())); }