---
description: Learn how selection indicators work
---

# Selection Indicator

## Overview

The selection system supports few ways to set up indicators with <mark style="color:blue;">**SelectableUnit**</mark> component. While indicators are **optional**, they enhance the player experience by visually highlighting selected units.

Selection indicator is defined per game object unit as you might need to resize indicators for different units, or perhaps different visuals for various unit types that you may support in your game.

<figure><img src="https://425343605-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fml7vS0D5xN2Q8jQMEmBv%2Fuploads%2FlXHRQCbNLNQ5NimkSoRt%2FScreenshot%202024-05-01%20at%2018.52.09.png?alt=media&#x26;token=455e50ae-6e63-49c6-990f-67bd2c16e4a8" alt="" width="188"><figcaption><p>Indicator example</p></figcaption></figure>

## Supported components

There are few components already provided by Unit Selection package for easy setup. Pick the one which suits your game needs best. If you do not find one that does, you can implement your own and if you believe a common use case is missing, feel free to drop a feature request on [Discord](https://discord.com/invite/tVCSQPvkHg) or send us an [Email](https://email:support@tomazravljen.com).

### Sprite Renderer

<mark style="color:blue;">**SpriteRendererSelectionIndicator**</mark> provides you with options to set different **sprites** and **colors** for selected or highlighted states.

<figure><img src="https://425343605-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fml7vS0D5xN2Q8jQMEmBv%2Fuploads%2FzfUmsM93ANLxh8qZET2r%2Fimage.png?alt=media&#x26;token=9c458b8e-3356-47b6-a1c8-46072a163a73" alt="" width="563"><figcaption><p>SpriteRendererSelectionIndicator component</p></figcaption></figure>

#### Rendering technique

You can use Sprite renderer to render simple texture in world. You can set your own material, flip texture, add sorting layer, etc. This technique is shown in the Demo scene and is provided with 2 different ring textures (<mark style="color:green;">**Selection Indicator - Sprite**</mark>).

**Limitations:** This works well when you have a plain for terrain and no hills as it does not project to terrain/ground mesh.

### Mesh Renderer

<mark style="color:blue;">**MeshRendererSelectionIndicator**</mark> provides you with options to set different **mesh** and **materials** for selected or highlighted states.

<figure><img src="https://425343605-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fml7vS0D5xN2Q8jQMEmBv%2Fuploads%2FcbFIbxLtslLN1O01hEZ6%2Fimage.png?alt=media&#x26;token=f1c48481-ff57-47a2-9c4d-2b405fc7443d" alt="" width="563"><figcaption><p>MeshRendererSelectionIndicator component</p></figcaption></figure>

#### Rendering technique

You can create your own custom shader for rendering textures using depth and use it with **MeshRenderer**. There are few approaches, but one that works very similar to Decals can be seen in this [**youtube tutorial**](https://www.youtube.com/watch?v=f7iO9ernEmM).&#x20;

**Limitations:** Simple shaders like the one in the link above will project the texture on all meshes, even units and trees alike. For desired effect more complex solution might be needed, however there are still Decals.

### Game Objects & Decals

<mark style="color:blue;">**GameObjectSelectionIndicator**</mark> provides you with simple interface to specify a game object for **selected** state and another for **highlighted** state.

<figure><img src="https://425343605-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fml7vS0D5xN2Q8jQMEmBv%2Fuploads%2F9OGRy3mZooWaqd5ktMbU%2Fimage.png?alt=media&#x26;token=c6fb1777-886d-4c26-86e2-3153da2736c1" alt="" width="563"><figcaption><p>GameObjectSelectionIndicator component</p></figcaption></figure>

#### Rendering technique

One of the most common practices is most likely Unity's Decals ([Unity documentation](https://docs.unity3d.com/Manual/visual-effects-decals.html)). Specially when using **URP** and **HDRP**.

**Limitations**: As far as I am aware only **High-Definition Rendering Pipeline** can specify which layers to project the texture on. **Universal Rendering Pipeline** cannot specify layers and **Built-in Rendering Pipeline** projectors have more limitations.&#x20;

## Customise

If none of the existing options suits your needs, you are free to implement custom components for a tailored approach with <mark style="color:blue;">**ASelectionIndicator**</mark> .

```csharp
public abstract class ASelectionIndicator : MonoBehaviour
{
    public abstract void Select();
    public abstract void Highlight();
    public abstract void Clear();
}
```
