---
description: Guide on how to integrate Unit Selection with Unit System entities.
---

# Unit Selection

### Overview&#x20;

This page is for guiding you through the process of basic integration for [**Selection System**](https://assetstore.unity.com/packages/tools/input-management/rts-unit-selection-v2-0-284090) package. Refer to the [**Selection Guide**](https://travljen.gitbook.io/unit-selection) if you need more information.

### 1. Selection & Units

For scene unit selection to work, you only need these two things:

* **Selection System** prefab in **scene** and configure it (and it's visuals)
* `SelectableUnit` and additionally `ManagedUnitObject` components to your **units**.

Now this will already work for selecting and highlighting units by the player. However since this is a separate package, we need to connect selection and interaction for the player.

<figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FgEmqYDC2ves3ZvZNaXAM%2Fimage.png?alt=media&#x26;token=583c9d34-19e9-4054-a206-17a28155d476" alt="" width="317"><figcaption><p>Selection components on Unit</p></figcaption></figure>

### 2. Sync Player Selection

If you are manually managing interactions and UI for selected units, you can **skip this step**.

However if you are using provided **Player UI** prefab, then `EntitySelectionManager` is used to communicate selection changes to those scripts. For this we have provided 2 basic scripts that simplify the integration process.

Find and add **Player Selection (Unit Selection)** prefab to your scene. This includes:

* `PlayerUnitSelectionManager` script which replaces `EntitySelectionManager`. This manages the communication between the `EntitySelectionManager` interface and `UnitSelector` to make sure the **data is synced**.
*   Additionally we have 2 scripts for filtering selection, both may be removed if undesired:

    * `MultiSelectionFilter` script for basic **Strategy filtering behaviour**, this restricts multi selection to only owned units of the player; when dragging to select multiple units, only owned ones are selected. Does not impact single selection behaviour.
    * `UnitStructureSelectionFilter` script, similar to the previous one it filters out units with buildable capabilities on multi-selection, but only when non-building is present. This means that drag to select can select buildings, as long as there is no other unit present in selection. Otherwise those units will be prioritised.



    <figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FyRQnrv7Xzy6yvaMslr9z%2Fimage.png?alt=media&#x26;token=43f0ce7c-45ed-4698-9930-8c1ba6a9edbb" alt="" width="346"><figcaption><p>Player selection components</p></figcaption></figure>
