Unit Selection
  • Welcome
    • πŸ‘‹Hello
    • πŸ—ΊοΈRoadmap
    • ⛑️Support & Community
    • πŸŽ“Changelog
  • Getting started
    • πŸ”ŒImport package
    • πŸ› οΈAdd selection to scene
    • 🦲Add selection to units
    • β›³Add visuals to units
  • How it works
    • 🎯Active Selections
    • 🫡Unit Selector
    • πŸ”’Quick Access Selector
    • ⬛Selection Area
      • πŸ”²2D Rectangle
      • 🧊3D Cube
    • πŸ’ Selectable Unit
      • πŸ“Selection Bounds
      • β­•Selection Indicator
    • Selectable Group Unit
    • ⌨️Input Controls
    • πŸ‘·β€β™€οΈUnit Management
Powered by GitBook
On this page
  • Overview
  • Supported components
  • Sprite Renderer
  • Mesh Renderer
  • Game Objects & Decals
  • Customise
  1. How it works
  2. Selectable Unit

Selection Indicator

Learn how selection indicators work

PreviousSelection BoundsNextSelectable Group Unit

Last updated 1 year ago

Overview

The selection system supports few ways to set up indicators with SelectableUnit 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.

Supported components

Sprite Renderer

SpriteRendererSelectionIndicator provides you with options to set different sprites and colors for selected or highlighted states.

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 (Selection Indicator - Sprite).

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

MeshRendererSelectionIndicator provides you with options to set different mesh and materials for selected or highlighted states.

Rendering technique

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

GameObjectSelectionIndicator provides you with simple interface to specify a game object for selected state and another for highlighted state.

Rendering technique

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.

Customise

If none of the existing options suits your needs, you are free to implement custom components for a tailored approach with ASelectionIndicator .

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

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 or send us an .

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 .

One of the most common practices is most likely Unity's Decals (). Specially when using URP and HDRP.

πŸ’ 
β­•
Discord
Email
youtube tutorial
Unity documentation
Indicator example
SpriteRendererSelectionIndicator component
MeshRendererSelectionIndicator component
GameObjectSelectionIndicator component