Advanced: Rebinding

Self-regulating text tooltips.

为ATM开发的本地化系统允许调用支持按键重绑定或其他值的文本工具提示。为此,需要一个自调整文本,它直接从CSV表中获取其值。它可以显示在场景上并手动分配,或嵌入到工具提示预制体中并赋予LocalizedTooltip组件。

  1. 在表中,创建带有占位符的翻译行。重要的是使用花括号,如{var}。例如:

在乌克兰语中: Натисніть {key} щоб взаємодіяти

在英语中: Press {key} to interact

在日语中,{key}为了自然性而重新定位: {key}キーでインタラクト

  1. 从脚本调用文本时,通过ReplacePlaceholders()将值插入占位符。您可以为{key}替换任何内容,甚至是玩家输入的按键。文本将以已调整的词序返回。

using AutomaticTutorialMaker;

[SerializeField] private InputStringsScriptableObject textStrings;

var keyToInteract = "E"; // the value that will fill the placeholder in the text

objectText.text = textStrings.ReplacePlaceholdersByKey("key_interaction_tip", keyToInteract); // it will return the text depending on the current language

// 🇺🇦→ Натисніть E щоб взаємодіяти
// 🇬🇧→ Press E to interact
// 🇯🇵→ Eキーでインタラクト

Try the free Localization System Mini to practice →arrow-up-right

Last updated