public void UpdateIsSelected() { if (Input.GetMouseButtonUp(0) && CameraBehavior.Selection.width * CameraBehavior.Selection.height > 2) { if (CameraBehavior.Selection.width < 0) { CameraBehavior.Selection.x += CameraBehavior.Selection.width; CameraBehavior.Selection.width = -CameraBehavior.Selection.width; } if (CameraBehavior.Selection.height < 0) { CameraBehavior.Selection.y += CameraBehavior.Selection.height; CameraBehavior.Selection.height = -CameraBehavior.Selection.height; } Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position); camPos.y = CameraBehavior.InvertMouseY(camPos.y); Selected = CameraBehavior.Selection.Contains(camPos); } CheckUnitClick(); if (Selected) { SetSelectedColor(Color.red); } else { SetSelectedColor(Color.white); } }