private void MouseActivity() { if (Input.GetMouseButtonDown(0)) { buildSelectionZone(); } if (Input.GetMouseButtonDown(1)) { RightMouseClick(); } if (Input.GetMouseButton(0)) { if (colliderSelectionZone != null && !colliderSelectionZone.Value.Contains(Input.mousePosition)) { colliderSelectionZone = null; } } if (Input.GetMouseButtonUp(0)) { if (colliderSelectionZone != null) { colliderSelectionZone = null; LeftMouseClick(); } else { Vector3 center = Camera.main.ScreenToViewportPoint(selectionZone.Zone.center); Collider[] colliders = Physics.OverlapBox(center, new Vector3(selectionZone.Zone.size.x, 1, selectionZone.Zone.y)); if (colliders.Length == 1) { LeftMouseClick(); } else if (colliders.Length > 1) { GameObject group = Instantiate(prototype); group.transform.parent = gameObject.transform; UnitGroup uGroup = group.GetComponent <UnitGroup>(); Debug.Log(uGroup.Group); foreach (Collider c in colliders) { if (c.gameObject.GetComponent <Unit>() != null) { uGroup.Group.Add(c.gameObject.GetComponent <SteeringBehavior>()); Debug.Log(c.gameObject.name); } } player.SelectedObject = uGroup; uGroup.GetComponent <Unit>().SetSelection(true, player.hud.GetPlayingArea()); } } selectionZone.enabled = false; } }