UI Toolbox ロゴUI Toolbox
サポート

このページは翻訳です。サポートと動画チュートリアルは主に英語で提供しており、英語版のページが正式な内容です。 英語版

FloatingTextLayer

FloatingTextLayer は、3D シーンの一点から浮かび上がってフェードアウトするテキストを表示します。ダメージ数字、回復、クリティカルヒット、"Stunned" のようなステータステキストです。短時間に 1 つのターゲットに当たったヒットは、1 つの数字に加算されます。

夕暮れの風景の上に浮かぶダメージ、クリティカル、回復、状態のテキスト夕暮れの風景の上に浮かぶダメージ、クリティカル、回復、状態のテキスト

ビデオチュートリアル: World-space HUD。すべてのビデオ: Video tutorials。デモシーン: FloatingTextLayerDemo.unity。

UXML でレイヤーを加えるには:

<ui:VisualElement class="hud-root">
    <tb:FloatingTextLayer name="floatingText" class="gold-layer" />
</ui:VisualElement>

ダメージと回復を表示するには:

var texts = root.Q<FloatingTextLayer>("floatingText");

// On a transform: the text follows the enemy
texts.Show(enemy.transform, "12");
texts.Show(enemy.transform, "48", FloatingTextKind.Critical);
texts.Show(player.transform, "+25", FloatingTextKind.Heal);
texts.Show(enemy.transform, "Stunned", FloatingTextKind.Status);

// At a point: the text stays where the hit was
texts.Show(hit.point, "7");

// Over an element of the UI, with no camera: the text rises from the
// wood counter
texts.Show(woodCounter, "+1 Wood", FloatingTextKind.Status);

テキストをより高く浮かび上がらせ、長く残すには:

<tb:FloatingTextLayer rise="100" duration="1600" spread="40" />
メンバー 説明
Camera ゲームビューのカメラ。null (既定) なら Camera.main を使います。
Viewport Camera のレンダーテクスチャを表示する要素。カメラが画面に描くなら null。
Rise (rise) テキストがその時間をかけて浮かび上がるピクセル数。既定は 60。
Spread (spread) 新しいテキストのランダムな横方向のずれの幅 (ピクセル)。同じ点のテキストが重ならないようにします。最小は 0。既定は 20。
Duration (duration) テキストが表示されるミリ秒。最小は 50。既定は 1000。
StackTime (stack-time) ターゲット上の数字が、この時間 (ミリ秒) 以内に来ると、そのターゲットの最後の数字に加算されます。既定は 300。0 でオフ。
MaxActive (max-active) 同時に表示されるテキストの最大数。それを超えると、新しいテキストが最も古いものを再利用します。既定は 32。
Show(position, text, kind) シーンの固定点から浮かび上がるテキストを表示します。kind の既定は Damage です。
Show(transform, text, kind) transform から浮かび上がるテキストを表示します。テキストは transform に追従します。
Show(element, text, kind) レイヤーのパネル内にある要素 (スロット、ボタン、カウンターなど) の中心から浮かび上がるテキストを表示します。カメラは不要です。テキストは要素に追従します。
Clear() すべてのテキストを取り除きます。
FloatingTextLayer.KindClass(kind) 種類のクラス。たとえば tb-floating-text--heal。

ヒント:

texts.Show(chest.transform, "+50 gold", FloatingTextKind.Custom);

スタイル

クラス 要素
tb-floating-text-layer レイヤー。絶対位置で、親を埋めます。
tb-floating-text__root テキストの保持者。テキストとともに動く点です。
tb-floating-text 1 つのテキスト。太字、--tb-font-size-lg、点を中心にして、縁取りがあります。
tb-floating-text--damage ダメージのテキスト: --tb-color-text-danger。
tb-floating-text--critical クリティカルヒット: --tb-color-warning。
tb-floating-text--heal 回復: --tb-color-success。
tb-floating-text--status ステータスのテキスト: --tb-color-text-muted、--tb-font-size-sm、斜体。
tb-floating-text--custom 種類 Custom のテキスト。ルールはありません。自分で与えてください。
変数 説明
--tb-color-hud-outline テキストの縁取りの色。既定は rgba(0, 0, 0, 0.8)。
/* Gold texts of kind Custom in the layer with the class gold-layer */
.gold-layer .tb-floating-text--custom {
    color: rgb(255, 210, 60);
    font-size: 20px;
}

/* Larger damage numbers */
.hud-root .tb-floating-text--damage {
    font-size: 24px;
}

FloatingTextLayerDemo シーンには、戦闘のダメージ数字、クリティカルヒット、回復、ステータスの言葉、点上またはプレイヤー上のピックアップのテキスト、テキストの動き、3 つの見た目があります。