Theming and strings
A plugin can add a color preset to the SheetForge windows and register UI strings that follow the user's language. This page covers both contracts, and the convention for keeping multi-line text in one cell. All three are opt-in.
Add a color preset
SheetForge paints its own windows from a small vocabulary of color slots: surfaces, outlines, text, semantic colors and the marks on staged edits. A color preset re-colors the slots it cares about. Every other slot keeps the product default.
To add a preset, implement ISheetForgeThemePlugin.
public sealed class SkillsPlugin : /* ... */, ISheetForgeThemePlugin
{
public void RegisterThemes(ThemeRegistry themes)
{
themes.Register(new SheetForgeTheme(
"skills.forge", // registry key (unique; the built-in ids are reserved)
"Forge (Skill demo)", // your own display string
new Dictionary<ThemeColorSlot, uint> // dark screens
{
{ ThemeColorSlot.Accent, 0xff9a4d },
{ ThemeColorSlot.Canvas, 0x120d0a },
{ ThemeColorSlot.Text, 0xe8dccf },
},
new Dictionary<ThemeColorSlot, uint> // light screens
{
{ ThemeColorSlot.Accent, 0x9c4a10 },
{ ThemeColorSlot.Canvas, 0xf7f2ec },
{ ThemeColorSlot.Text, 0x2b1f16 },
}));
}
}The first argument is the registry key. It must be unique, and the built-in ids are reserved. The second argument is the display string. Display strings are yours, so they need no Core Loc key.
Color values
Colors are 0xRRGGBB. The top byte is ignored. The Core references no engine type, so there is no UnityEngine.Color here.
Translucent surfaces, such as badge fills and the modal scrim, are derived from a slot color plus a fixed alpha. You set the color, not the alpha.
Dark and light maps
Cover both editor skins: supply a dark map and a light map. The user's brightness choice picks one. The choices are follow editor, always dark and always light.
Slots that you leave out fall back to the product default for that brightness. A three-slot preset is normal.
How a preset takes effect
Registering a preset does not apply it. Your preset appears in the Data Studio toolbar's theme menu, under Color preset, beside the built-in Default and High contrast. Only the user's pick takes effect.
Rejected ids
Register throws for each of the ids below. The failure is surfaced as a PluginRegistrationConflict.
- A blank id.
- A duplicate id.
- A reserved built-in id, which is
defaultorhighContrast.
What a theme cannot restyle
The Data Studio, its menus and dialogs, the plugin market and the Getting Started window draw every control themselves, so a theme reaches all of them. A theme cannot restyle what SheetForge draws inside Unity's own Inspector: the settings asset and baked database inspectors keep following the editor skin. Plugin extension limits lists this boundary with the others.
Register plugin UI strings
The labels that your plugin shows can follow the user's language. That covers inspector actions, widget captions and the declarative surfaces in Authoring surfaces.
Register a sentence for each language under a key. Loc.Tr consults this overlay before the product tables, and the browser's t() does the same.
using System.Collections.Generic;
using SheetForge.Core.Model;
using SheetForge.Core.Plugins;
public sealed class ExampleLocStrings : ISheetForgeStringsPlugin
{
// Prefix keys with your pack name so packs never collide.
public const string BrakeActionKey = "plugin.skillsDemo.action.setBrake";
public void RegisterStrings(StringOverlayRegistry strings)
{
strings.Register(BrakeActionKey, new Dictionary<string, string>
{
{ "en", "Set reaction brake to 0.25s" },
{ "ko", "반응 제동을 0.25초로 넣기" },
});
// Or one language at a time: strings.Register(key, "en", "…");
}
}Your strings live in an overlay beside the core tables, consulted before them and never merged into them. The product's rule that every string exists in all 10 languages is untouched.
Registering is optional. An unregistered key keeps displaying verbatim. This contract is an upgrade path, not a requirement.
Put the strings in your main assembly
This contract lives in the Core, so put the strings plugin in your main assembly. Both hosts then show your plugin's labels, because the browser only ever loads the main DLL. A strings plugin that sits in the editor companion assembly leaves the web app showing raw keys.
Language codes and fallback
Languages are IETF codes, such as "en", "ko", "zh-Hans" and "pt-BR". They are matched case-insensitively.
Register English at minimum. The lookup falls back from the requested language to English, and then to a miss. A user in any other language reads your English sentence, not the raw key.
A code that the product does not know is rejected with a reason. It is not folded into English, because a typo that silently became English would be untraceable.
Product keys
Product keys cannot be overridden. A registration that names a built-in key is refused, so an overlay can never make the UI disagree with the product's own sentences. The overlay is for new keys.
Menu labels in particular are generated from the language tables directly. An overlay that could rewrite them would make the guidance text and the real menu path disagree.
Duplicate and empty registrations
Duplicate registrations across plugins keep the first found, with a reason recorded. If the last registration quietly won, the screen would depend on plugin install order.
Empty keys and empty values are refused too.
Every refusal is a developer-facing English line. The audience is the plugin author, not the end user.
The demo strings plugin
The demo ships this contract at Assets/SheetForge.PluginDemo/ExampleLocStrings.cs. The file is in the main assembly, for the reason above.
It registers the labels that the demo's inspector action and declarative surfaces display. Studio extensions describes inspector actions.
Keep multi-line text in one cell
Dialogue, descriptions and scripts are long text. A real newline can never live inside a cell, so a domain with long text works with that rule through a three-part convention. Your plugin carries the whole convention.
Why a cell cannot hold a newline
The pipeline's input is TSV, where a tab separates cells and a newline separates rows. A cell that holds either character has no representation at all. This is a design constant of the format, not a gap waiting to be closed.
Every source enforces the rule at the door. None of them lets a corrupted grid through.
| Source | What happens |
|---|---|
| CSV and xlsx readers | Report UnsupportedCellCharacter with the cell's coordinate. Every offending cell is collected, not just the first |
| Google fetch | Does the same |
.tsv file | The character was already the row separator |
The three parts
The convention has three parts.
| Part | What you do |
|---|---|
| 1 | Pick an escape and write it into your parser |
| 2 | Give the cell a real editor |
| 3 | Know the one place the convention does not reach |
Pick an escape
The conventional choice is a literal two-character \n in the sheet. Your parser unescapes it on the way in and re-escapes it on the way out.
public sealed class ProseCellParser : ICellValueParser, ICustomCellType
{
public string TypeName => "Prose";
public Type ValueType => typeof(string);
public bool TryParse(CellParseContext ctx, string text, out object value)
{
value = text.Replace("\\n", "\n"); // sheet spelling → the value your game sees
return true;
}
public bool TryRender(object value, out string text, out string reason)
{
reason = null;
text = ((string)value).Replace("\r\n", "\n").Replace("\n", "\\n"); // the exact reverse
return true;
}
}Make the two directions exact inverses and prove it. TryRender is what Export and Push write back. If it does not undo TryParse character for character, a "sheet → import → export → sheet" round trip rewrites text nobody edited.
The sample normalizes \r\n to \n on the way out. That keeps a Windows-authored value from alternating between two spellings on successive exports.
A single test is enough to lock the round trip. The test renders a parsed value and compares it to the original cell text.
Enums and cell types describes the two parser interfaces.
Give the cell an editor
A \n-escaped value is unpleasant to type in a one-line box. A custom cell widget is for exactly that case. Studio extensions describes custom cell widgets.
Register an IStudioCellEditorProvider for "Prose" that returns a multi-line TextField (multiline = true). The widget shows the value with real newlines and commits it re-escaped.
Commit on focus-out with Commit, not per keystroke. That gives one undo step per edit session.
Newlines typed in the Google sheet
The convention does not reach one place. Someone who types Alt+Enter directly in the Google sheet creates a genuine newline in the live cell. That cell is refused on the next fetch, with a coordinate pointing at it. The refusal is fixable, but it is a refusal.
If the writers on your team author prose in the spreadsheet itself, do one of these:
- Say in your own documentation that long text is written with
\n. - Let them author it in the Data Studio cell widget from part 2, where the escaping happens for them.
Next steps
- Authoring surfaces
Describe Studio UI as data that the editor and the browser both draw.
- Studio extensions
Add graph widgets, inspector actions and custom cell widgets in the editor.
- Enums and cell types
Write the parser behind a custom cell type.
- Plugin extension limits
The boundaries of each plugin seam.