// Update is called once per frame void Update() { // Left Mouse Button if (Input.GetMouseButtonUp(0) && dragtime < 0.2f) { var mousePos = _camera.ScreenToWorldPoint(Input.mousePosition); var gridPos = _grid.WorldToCell(mousePos); //check if cell has unit var transform = GetUnitTransformInCell(gridPos); if (transform != null && transform.GetComponentInParent <AbstractUnit>() == SelectedUnit) { //this.SelectedUnit = transform.GetComponentInParent<AbstractUnit>(); //this.SelectedUnit.WhenLeftClicked(); } //check if direction change arrow was clicked else if (transform != null && transform.GetComponent <Arrow>() != null) { SelectedUnit.RotationArrowClicked(transform.GetComponent <Arrow>()); } //check if the cell is a movement selector cell, call "MoveTileClicked" on last selected unit. if (_moveSelectTileMap.HasTile(gridPos)) { SelectedUnit.MoveTileClicked(_grid.CellToWorld(gridPos)); } } // Right Mouse Button if (Input.GetMouseButtonUp(1)) { var mousePos = _camera.ScreenToWorldPoint(Input.mousePosition); var gridPos = _grid.WorldToCell(mousePos); var transform = GetUnitTransformInCell(gridPos); if (transform != null && transform.GetComponentInParent <AbstractUnit>() == SelectedUnit) { this.SelectedUnit.WhenRightClicked(); } } }