βSelection Indicator
Learn how selection indicators work
Last updated
Learn how selection indicators work
Last updated
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.
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 or send us an Email.
SpriteRendererSelectionIndicator provides you with options to set different sprites and colors for selected or highlighted states.
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.
MeshRendererSelectionIndicator provides you with options to set different mesh and materials for selected or highlighted states.
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.
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.
GameObjectSelectionIndicator provides you with simple interface to specify a game object for selected state and another for highlighted state.
One of the most common practices is most likely Unity's Decals (Unity documentation). 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.
If none of the existing options suits your needs, you are free to implement custom components for a tailored approach with ASelectionIndicator .