RealDocs

UUserWidget::SetVisibility

function UMG Blueprint Since 4.5
#include "Blueprint/UserWidget.h"
Access: public Specifiers: virtual

Description

Sets the visibility of the widget, controlling both rendering and hit-test behaviour. Common values are Visible, Hidden (not rendered, still takes up space), Collapsed (not rendered, takes no space), and HitTestInvisible.

Signature

virtual void SetVisibility(ESlateVisibility InVisibility)

Parameters

Name Type Description Default
InVisibility ESlateVisibility The visibility state to apply.

Return Type

void

Caveats & Gotchas

  • Hidden and Collapsed are different: Hidden leaves layout space, Collapsed does not. Switching between them can cause layout shifts.
  • ESlateVisibility::HitTestInvisible renders the widget but passes all input through to widgets below — useful for overlays that display info but shouldn't block clicks.
  • Visibility changes on a parent do not automatically propagate to children in a way that GetVisibility() reflects — child visibility is independent.

Example

Toggle widget visibility C++
// Show/hide without affecting layout:
MyWidget->SetVisibility(bShow ? ESlateVisibility::Visible : ESlateVisibility::Hidden);

// Show/hide and collapse layout space:
MyWidget->SetVisibility(bShow ? ESlateVisibility::Visible : ESlateVisibility::Collapsed);

See Also

Tags

Version History

Introduced in: 4.5

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.