0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【UE5】【C++】数値をFTextに変換する方法と、よく使う表示設定

0
Last updated at Posted at 2026-09-02

FText::AsNumber(value) だけでも変換可能ですが、

・小数点第◯まで表示したい
・0埋めを行いたい

などの場合、表示形式を指定したい場合は「FNumberFormattingOptions」 を使用します。

FNumberFormattingOptions Options;
FText NewText = FText::AsNumber(value, &Options);

Case1. 小数点第◯までを表示したい

float value = 10.789f;

FNumberFormattingOptions Options;

//小数点以下を1桁で表示
Options.MinimumFractionalDigits = 1;
Options.MaximumFractionalDigits = 1;

//FTextに変換
FText NewText = FText::AsNumber(value, &Options);

結果
スクリーンショット 2026-09-02 213731.png

Case2. 桁数の桁区切りカンマを非表示にする

float value = 1000000.0f;

FNumberFormattingOptions Options;

//カンマを非表示
Options.UseGrouping = false;

//FTextに変換
FText NewText = FText::AsNumber(value, &Options);

Options.UseGroupingがtrueの場合
スクリーンショット 2026-09-02 214014.png

Options.UseGroupingがfalseの場合
スクリーンショット 2026-09-02 213936.png

Case3. 0埋めの指定

float value = 5;

FNumberFormattingOptions Options;

//整数部を最低2桁で表示する
Options.MinimumIntegralDigits = 2;

//FTextに変換
FText NewText = FText::AsNumber(value, &Options);

結果
スクリーンショット 2026-09-02 214128.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?