-
Notifications
You must be signed in to change notification settings - Fork 5
Creating text mods
Learn how to add new text or modify existing text. Change how the game labels certain items, add text for your new weapon or translate an existing mod.
This tutorial is available directly in the SDK under
PB Mod SDK/Getting Started/Tutorials/Text edits. The SDK version can include interactive elements such as buttons automatically selecting project assets. Make sure you are in the right scene (game_main_sdk or game_extended_sdk). You should see DataModel and ModManager in the Hierarchy window. If you're unsure how to find the right scene, use the scene buttons in the Getting Started window.
By now you have probably noticed how every collection database has separate buttons for loading and saving text. Looking at the configs directly, we can see how they never contain the text you see in the database inspectors and in the game. So, where is that text coming from, and how do you modify it?

To facilitate localization, we store text separately from data. Based on the name of the config and its database (as well as selected language), the game automatically resolves text to display to the player.

If you're interested in inspecting the source files involved in this, check Configs/TextLibrary. The data hierarchy goes like this:
Language (e.g. English)
└ Sector (e.g. subsystems)
└ Text entry (e.g. name of the heavy MG)

Since this tutorial involves editing the config databases, this tutorial assumes you have set up the mod project for config editing. Select a mod and enter the config editing mode before taking the next steps.

Modifying text is as simple as modifying other data: just input a new value in the database inspector. The key part is that your changes need to be saved in a different place: the text library. Press "Save Text" after you're done with your changes.

Many mods will involve adding new configs, such as new weapons. These configs will not have any associated preexisting text in the library and will start out with empty text fields. The process is the same for these cases: enter your preferred text and press "Save Text" in addition to "Save Data".

When you export your mod, the SDK will check the library text sectors in your mod project Configs folder. You might have added new text or modified existing text: the exact extent of the changes can be detected by comparing your files with the sector files in the SDK. The changes are detected and automatically added to a new part of the mod config: text edits.
These edits are saved into per-sector YAML files under the LocalizationEdits folder. At runtime, the game will read these files and patch the text sectors. The idea is similar to config editing definitions, allowing your mods to avoid including entire sector files.

The editor tools are locked to using the English text library. However, you can still use the text editing system to translate your mod into additional languages. To do that, add a new entry to the Languages dictionary and fill it in the same way as the autogenerated English section.
To speed up setup of additional languages, you can use the copy/paste functionality available for all reference objects Unity inspectors. Just right-click on the ModConfigLocEdit header of the English section, click Copy, add a new section for your intended language, right click the header and click Paste. Fill the fields and your mod will now patch more than just English text!
This wiki is a work in progress. Please make sure to check the built-in tutorials within the SDK or the modding articles on the game wiki to supplement this page. If you get stuck or experience a bug, please don't hesitate to ask questions in the #phantom-modding channel of the official Discord server. We can't wait to see what you create!