# 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="/files/qblOYRS7km3mz1LiE5vD" 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](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="/files/Skj5JocCY5HIwlOh4b7J" 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="/files/uPPjbA0aAuFCSbNxRybW" 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="/files/G0trz7SJDKhqQ6DSciVM" 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();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://travljen.gitbook.io/unit-selection/how-it-works/selectable-unit/selection-indicator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
