// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(1)) // Right click, move the unit { target = Camera.main.ScreenToWorldPoint(Input.mousePosition); target.z = this.gameObject.transform.position.z; MoveObject(); } else if (Input.GetMouseButtonDown(0)) // Left click, determine if its a selection or deselection { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 mousePos2d = new Vector2(mousePos.x, mousePos.y); RaycastHit2D hit = Physics2D.Raycast(mousePos2d, Vector2.zero); if (hit.collider == null || !(hit.collider.tag == "PlayerUnit" || hit.collider.tag == "Building" || hit.collider.tag == "GameButton")) { //Debug.Log(hit.collider.ToString()); SelectionHandler.ClearActiveSelections(); SelectionHandler.ClearSelections(); SelectionHandler.SelectedObjects.Clear(); UiManager.isBuildingDisplay = false; UiManager.isUnitDisplay = false; //BuildingManager.DeselectCurrentBuilding(); } } }