← SEARCHABLE ARCHIVE
Unreal Engine · 2026-07-02

UI contract between C++ and WBP

Separating Behavior and Design with BindWidget

INTERACTIVE READING MODE →

The articles written on this blog were created with the goal of teaching. Also, the information in the article may be incorrect, so please be careful.

Just because you create Unreal UI in C++, there is no need to completely eliminate the Widget Blueprint. In ProjectTB, it was divided into contracts, with C++ responsible for operation and WBP responsible for layout and style.

BindWidget is a naming contract

UPROPERTY(meta = (BindWidgetOptional))
TObjectPtr<UTextBlock> UnitNameText;

UPROPERTY(meta = (BindWidgetOptional))
TObjectPtr<UButton> SettingsButton;

If there is a widget with the same name and a compatible type in WBP, it is automatically connected. BindWidgetmust exist,BindWidgetOptionalEven without , C++ generation does not fail.

Optional contracts are useful for projects that gradually modify the UI. Instead, you must check pointers before using them in C++.

if (UnitNameText)
{
    UnitNameText->SetText(Unit->GetDisplayName());
}

Prevent WBP from continuously polling data

If each tick causes WBP to find the GameMode and read health and money, it is difficult to track the data flow. It is clear that it is better to call the Widget's update function when the C++ state changes.

Change combat state
    ↓
C++ verified
    ↓
RefreshBattleState()
    ↓
Update linked TextBlock

Keep contract documents together

ProjectTB'sWBP_MainHUD_Contract.mdInSelectionSwitcher, HoverUnitNameText, TimelineTextThe same exact name and type are written. WBP workers can know what widgets to create without having to read all of C++.

The question between C++ and Blueprint is not which is better. Problems arise when the name, type, call direction, and widgets that do not need to be removed are not specified.