RTS UI Components
RTS UI Components
Enemy Masses provides specialized UI components for displaying agent health bars, status effects, and integrating with the crowd system's health events. These components are designed for RTS and strategy games where you need to visualize the state of selected units or all units on the battlefield.
EnemyMassesRTSHealthBarUI

The EnemyMassesRTSHealthBarUI component displays health bars for Enemy Masses agents, supporting both individual unit displays and aggregated averages. It automatically reacts to selection changes and health events for optimal performance.

Quick Setup
Create a Canvas in your scene (if you don't have one)
Create an empty GameObject as a child of the Canvas
Add the
EnemyMassesRTSHealthBarUIcomponentCreate a UI Slider to use as the health bar template
Assign the Slider to the Health Bar Prefab field
The component automatically finds the EnemyMassesRTSController and EnemyMassesCrowdController in your scene if not explicitly assigned.
Display Modes
Display Scope
Selected Agents Only
Show health bars only for currently selected agents
Always
Show health bars for all agents (respects faction filter)
Display Mode
Individual Agents
One health bar per agent
Average
Aggregated health bars based on grouping
Average Grouping
When using Average display mode:
Combined
Single bar showing average of all visible agents
EnemyCrowd
One bar per faction/type (EnemyCrowd asset)
SpawnGroup
One bar per spawn group
Settings Reference
References
RTS Controller
Reference to selection controller (auto-resolved)
Crowd Controller
Reference to crowd controller (auto-resolved)
Health Bar Prefab
UI Slider template to clone for each bar
Health Bar Container
Parent transform for spawned bars
Display Settings
Display Scope
When to show bars
Selected Agents Only
Display Mode
Individual or averaged
Individual Agents
Average Grouping
How to group averages
Combined
Include Dead Agents
Show bars for dead agents
false
Include Dead Agents In Average
Include 0-health agents in calculations
true
Preserve Dead Selection In Average
Keep dead agents in average so it doesn't jump up
true
Faction Filter
Filter by player-controlled factions
All
Max Bars
Limit number of bars (0 = unlimited)
50
Update & Performance
Update Interval
Seconds between UI refreshes
0.1
Use Aggregate Cache
Event-driven health tracking for averages
true
Aggregate Resync Interval
Seconds between full cache rebuilds
1.0
Hide Template At Runtime
Disable the template Slider in scene
true
Colors
Full Health Color
Color at 100% health
Green
Mid Health Color
Color at mid health
Yellow
Low Health Color
Color at low health
Red
Mid Health Threshold
Percent to switch to mid color
0.6
Low Health Threshold
Percent to switch to low color
0.3
Labels
Show Labels
Display text labels on bars
false
Label Child Path
Path to find Text component in slider
"Label"
Combined Label
Label for combined averages
"Combined"
Selected Label
Label for selection averages
"Selected"
Enemy Crowd Label Format
Format for faction bars
"{faction} {type} ({index})"
Spawn Group Label Format
Format for spawn group bars
"Spawn Group {group}"
Agent Label Format
Format for individual bars
"Agent {index}"
Label Tokens:
{faction}- Faction name from EnemyCrowd{type}- Enemy type name from EnemyCrowd{index}- Agent index{group}- Spawn group ID
Creating the Health Bar Template
Your health bar Slider should have:
Background - The unfilled portion
Fill Area > Fill - The filled portion (colored by component)
Label (optional) - A Text component for labels
Set the Slider's Interactable to false since it's display-only. The component will control the value and fill color automatically.
Faction Filtering
Filter which agents' health is displayed:
All
Show all agents
Player Controlled Only
Only show agents from player-controlled factions
Non Player Only
Only show enemy/neutral agents
Faction filtering requires your EnemyMassesRTSController to have Player Controlled Factions configured.
EnemyMassesRTSStatusEffectUI
The EnemyMassesRTSStatusEffectUI component displays active status effects (buffs, debuffs, DoTs, crowd control) on agents. Perfect for showing what's affecting your selected units.

Quick Setup
Create a UI container (Panel or empty GameObject under Canvas)
Add the
EnemyMassesRTSStatusEffectUIcomponentCreate a status effect entry prefab with an Image and optional Text
Assign the prefab to Status Effect Prefab
Settings Reference
References
RTS Controller
Reference to selection controller (auto-resolved)
Crowd Controller
Reference to crowd controller (auto-resolved)
Status Effect Prefab
Template GameObject to clone per effect
Status Effect Container
Parent transform for spawned entries
Display Settings
Display Scope
When to show effects
Selected Agents Only
Faction Filter
Filter by player-controlled factions
All
Include Dead Agents
Show effects on dead agents
false
Max Items
Limit number of entries (0 = unlimited)
100
Category Filters
Show Crowd Control
Display stuns, slows, roots, etc.
true
Show Damage Over Time
Display poison, burn, bleed, etc.
true
Show Debuffs
Display armor break, weaken, etc.
true
Show Buffs
Display regeneration, damage buff, etc.
true
Icons
Icon Child Path
Path to find Image in entry prefab
"Icon"
Fallback To Any Image
Use first Image if path not found
true
Icon Overrides
Per-effect-type custom icons
(empty list)
Default Buff Icon
Fallback icon for buffs
-
Default Debuff Icon
Fallback icon for debuffs
-
Default Dot Icon
Fallback icon for DoTs
-
Default Crowd Control Icon
Fallback icon for CC effects
-
Colors
Colorize Icons
Tint icons by category
true
Colorize Labels
Tint labels by category
false
Buff Color
Color for buff effects
Green
Debuff Color
Color for debuff effects
Red
Dot Color
Color for DoT effects
Orange
Crowd Control Color
Color for CC effects
Yellow
Labels
Show Labels
Display text labels
true
Label Child Path
Path to find Text in entry prefab
"Label"
Label Format
Format string for labels
"{effect} {remaining}"
Show Stacks
Show stack count in label
true
Show Stacks Only When Stacked
Hide "x1" stacks
true
Show Remaining Time
Show time remaining
true
Remaining Time Format
Numeric format
"0.#"
Remaining Time Suffix
Suffix after time
"s"
Permanent Label
Text for permanent effects
"Permanent"
Label Tokens:
{effect}- Effect name (e.g., "Poison", "Stun"){category}- Category name (e.g., "DamageOverTime"){stacks}- Stack count{remaining}- Time remaining with suffix{agent}- Agent index{faction}- Faction name{type}- Enemy type name
Status Effect Categories
The system organizes effects into four categories:
Crowd Control
Stun, Freeze, Sleep, Fear, Slow, Root
Disable or impair actions
Damage Over Time
Poison, Burn, Bleed, Curse
Periodic damage
Debuff
Armor Break, Weaken, Vulnerable
Stat reductions
Buff
Regeneration, Damage Buff, Shield
Stat increases
Creating Custom Icon Overrides
To use custom icons for specific effects:
In the Inspector, expand Icon Overrides
Click + to add an entry
Select the Effect Type (e.g.,
Poison,Stun)Assign your custom Sprite
RTSSelectionCommandPanel

The RTSSelectionCommandPanel is a command interface that appears when player-controlled units are selected. It provides buttons for combat stances (Offensive, Defensive, Hold Position) and a Stop command, with support for strict/non-strict modes.

Quick Setup
Create a UI Panel under your Canvas
Add the
RTSSelectionCommandPanelcomponentCreate buttons for each command (Offensive, Defensive, Hold, Stop)
Optionally add a Toggle for Strict Mode
Wire up the references in the Inspector
The panel automatically shows/hides based on whether player-controlled units are selected (configurable via Auto Hide When No Player Selection).
Combat Stances Explained
Offensive
Actively seeks enemies, helps allies under attack
Actively seeks enemies, ignores ally calls for help
Defensive
Only attacks when attacked, helps allies
Only attacks when attacked, ignores allies
Hold Position
Stays in place, attacks nearby enemies, helps allies
Stays in place, attacks nearby enemies, ignores allies
Strict Mode is useful when you want precise control over unit behavior. Non-strict mode creates more realistic "army" behavior where units support each other.
Settings Reference
References
RTS Controller
The RTS controller to receive commands
Panel Root
Root GameObject to show/hide
UI Elements
Strict Mode Toggle
Toggle for strict/non-strict stance mode
Offensive Strict Button
Button for Offensive stance
Defensive Strict Button
Button for Defensive stance
Hold Strict Button
Button for Hold Position stance
Stop Button
Button to cancel current actions
Visual Customization
Button Normal Color
Default button color
Dark blue-gray
Button Hover Color
Color when hovering
Lighter blue-gray
Button Pressed Color
Color when clicked
Bright blue
Button Selected Color
Color for active stance
Cyan
Button Disabled Color
Color when disabled
Very dark
Audio
Offensive Click Sfx
Sound when clicking Offensive
Defensive Click Sfx
Sound when clicking Defensive
Hold Click Sfx
Sound when clicking Hold Position
Stop Click Sfx
Sound when clicking Stop
Strict On Sfx
Sound when enabling Strict Mode
Strict Off Sfx
Sound when disabling Strict Mode
Command Audio Source
Optional AudioSource for playback
Command Sfx Pitch Variation
Random pitch variation (0-0.5)
Behavior
Auto Hide When No Player Selection
Hide panel when no player units selected
true
Stop Resets To Offensive
Stop also resets units to Offensive stance
true
How It Works
Selection Detection: The panel subscribes to
SelectionChangedevents from the RTS controllerFiltering: Only responds to player-controlled units (based on
playerControlledFactions)Visual Feedback: Highlights the button matching the majority stance of selected units
Command Dispatch: Button clicks call the appropriate method on the RTS controller
Post-Combat Reformation
When switching stances during combat, the panel automatically enables post-combat reformation:
Units that break formation to chase enemies will return to formation after combat
Switching from Strict to Non-Strict mode triggers reformation tracking
This creates realistic "units regroup after a skirmish" behavior
Scripting the Command Panel
Creating Custom Command Buttons
To add your own command buttons:
Health-Driven UI Events
The EnemyMassesCrowdController exposes events that fire when agent health changes, enabling you to build custom UI or trigger game logic.
Available Events
Subscribing to Health Events
Performance Considerations
The EventAgentHealthChanged event fires every time any agent's health changes. With thousands of agents, this can fire very frequently. Use the event for:
UI updates (with rate limiting)
Tracking specific agents
Spawning effects on health thresholds
For aggregate statistics, use EnemyMassesRTSHealthBarUI's built-in Aggregate Cache which batches updates efficiently.
Example: Damage Numbers
Example: Kill Counter
Best Practices
Health Bar UI
Use Aggregate Cache - Enable
Use Aggregate Cachefor average mode to avoid per-frame calculationsLimit Max Bars - Set
Max Barsto prevent performance issues with large selectionsTune Update Interval - Increase
Update Interval(e.g., 0.2s) if UI updates feel expensivePreserve Dead Selection - Enable to prevent average jumping when agents die
Status Effect UI
Filter Categories - Disable categories you don't use to reduce noise
Use Icon Overrides - Custom icons improve readability over color-coding alone
Show Remaining Time - Helps players plan around effect durations
Limit Max Items - Large battles can have hundreds of effects; limit display
Event Subscriptions
Always Unsubscribe - Remove event handlers in
OnDisable()to prevent memory leaksRate Limit Updates - Don't update UI on every health change; batch updates
Cache Agent Data - Store previous health values to calculate damage deltas
Null Check Controllers - Events fire during cleanup; check references aren't null
Related Components
EnemyMassesRTSController - Unit selection and commands
RTSCameraController - Camera controls
Status Effect System - Applying and managing status effects
Last updated