Skip to content
Tom_XV edited this page Sep 23, 2026 · 3 revisions

English | 日本語

The Text library is DragNWash.ModFramework.Text.dll, in the namespace DragNWash.ModFramework.Text. It lets mods see and replace every TextMeshPro text before the game shows it. Several mods can rewrite text, and they run one after another, in order.

[BepInDependency(GameText.Guid, BepInDependency.DependencyFlags.HardDependency)]

Rewriting text

private IDisposable _rewriter;

private void Awake()
{
    _rewriter = GameText.AddRewriter(MyMod.Guid, context =>
    {
        if (context.Text == "New Game")
        {
            context.Text = "Start Washing";
        }
    });
}

private void OnDestroy() => _rewriter?.Dispose();
  • A rewriter is called for every text the game sets, so keep it cheap. A dictionary lookup is fine, a regex over every string isn't.
  • order (default 0) sets the run order, lowest first. Later rewriters see the earlier changes in context.Text, but context.Source is always what the game set.
  • If your rewriter throws, the exception is logged with your GUID and the text is left as it was.

TextContext

Property Meaning
TMP_Text Component The component the text goes into
string Source The text the game set, before any rewriter
string Text The text that will be shown; set it to change it
bool FromPrefab True for text that was in a prefab and never set by code (menus, labels)
bool IsRefresh True when the text is re-applied by RefreshAll

Applying changes again

When something your rewriter depends on changes (the player picks another language, a setting flips), call:

GameText.RefreshAll();   // main thread only

It runs every rewriter again on every text on screen, starting from the text the game set.

Other members

Member What it does
const string Guid "com.tomxv.dragnwash.modframework.text"
const string Version The library's version
bool IsAvailable True when the hooks are installed on this game build
bool TryGetSource(TMP_Text component, out string source) The text the game last set on a component, before rewriters

Do not

  • Patch TMP_Text.text, SetText or similar yourself. That's the shared hook, and a second patch changes what every other mod sees.
  • Rewrite dialogue by matching the English text alone when the same line shows up in several places. Use Dialogue's TryGetLine alongside it so you know which line it is.

Clone this wiki locally