RealDocs

UKismetMathLibrary::SelectText

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPureUFUNCTION

Description

Returns A if bPickA is true, otherwise returns B. Use for conditional selection between two localized FText values, such as choosing a gender-appropriate pronoun or a state-dependent UI label.

Caveats & Gotchas

  • FText equality is based on the underlying string source, not its display string. Two FText literals that appear identical in a given culture may have different LOCTABLE keys and will not compare as equal, which can cause issues if you try to deduplicate the output downstream.
  • Both A and B are always evaluated — neither is skipped based on bPickA. If either text is assembled via FText::Format with expensive arguments, both formatting costs are incurred unconditionally.

Signature

static UE_INL_API FText SelectText(const FText A, const FText B, bool bPickA);

Parameters

Name Type Description Default
A const FText The localized text returned when bPickA is true.
B const FText The localized text returned when bPickA is false.
bPickA bool Selects A when true, B when false.

Return Type

FText

Example

Pick gender-appropriate pronoun text for a UI message C++
FText PronounText = UKismetMathLibrary::SelectText(
    NSLOCTEXT("UI", "Pronoun_He", "he"),
    NSLOCTEXT("UI", "Pronoun_She", "she"),
    bPlayerIsMale
);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.