Unreal Engine 5 · Blueprint → C++
Set Widget Visibility in Unreal Engine 5 C++UE Docs
The Set Visibility Blueprint node maps to UWidget::SetVisibility(ESlateVisibility) in C++, where the enum value controls whether a widget is visible, collapsed, hidden, or non-interactive.
Blueprint node & C++ equivalent
MyWidget->SetVisibility(ESlateVisibility::Hidden);
// Visible, Collapsed, Hidden, HitTestInvisible, SelfHitTestInvisibleWhat does the Set Visibility node do?
Set Visibility changes how a widget is displayed and whether it responds to input. In C++ you pass an ESlateVisibility value to SetVisibility, for example MyWidget->SetVisibility(ESlateVisibility::Hidden).
The five values are Visible, Collapsed, Hidden, HitTestInvisible, and SelfHitTestInvisible, each with different layout and hit-testing behavior.
The C++ equivalent and enum values
Hidden keeps the widget's space in the layout but makes it invisible, while Collapsed removes it from layout entirely so surrounding widgets reflow. Visible shows it and allows input.
HitTestInvisible shows the widget but lets clicks pass through it and all children, and SelfHitTestInvisible does the same but only for the widget itself, not its children. Choose based on whether you need the element to block mouse input.
Common mistakes
Confusing Hidden and Collapsed is the most frequent error. Hidden still occupies layout space; Collapsed does not. Use Collapsed when you want neighboring widgets to fill the gap.
If a widget visually appears but does not respond to clicks, check that its visibility is Visible and not one of the HitTestInvisible variants.
Frequently asked questions
How do you set widget visibility in UE5 C++?+
Call SetVisibility with an ESlateVisibility value, for example MyWidget->SetVisibility(ESlateVisibility::Hidden). Visible, Collapsed, Hidden, HitTestInvisible, and SelfHitTestInvisible are the options.
What is the difference between Hidden and Collapsed in UMG?+
Hidden makes the widget invisible but keeps its space in the layout. Collapsed removes it from the layout so other widgets reflow to fill the space.
How do I make a widget visible but click-through in C++?+
Use ESlateVisibility::HitTestInvisible to show the widget while letting mouse input pass through it and its children, or SelfHitTestInvisible to affect only the widget itself.