Bind CUI values to mod settings
A config binding ties a value in a CUI resource to a setting of your mod. Players change the setting on the Sunrise Mods page. The game applies it at the next start. Studio previews the setting’s default.
Declare a setting
- Open a project.
- Choose Build > Mod details….
- Under Config, press Add config entry.
- Type a Key, for example
hud_scale. - In Type, choose
int,floatorbool. - Set the Default.
- Optionally type a Name for the Mods page.
- Press Save.
Mods lists the rules for keys and defaults.
Bind a site
- Open a project.
- Open the CUI resource. A hierarchy has no config bindings.
- In the Inspector, press … (More) and choose Config bindings….
- In the list, select a site. Find scalar property or comparison filters it.
- In Setting, choose a setting of the same type.
- Press Bind setting.
- Repeat for other sites.
- Press Save bindings.
The save is one undo step. The Changes tab lists each binding as a Config row. A bound field is locked. The Inspector shows Bound to and the setting’s key. The CUI page shows the setting and previews its default.
Unbind
- In the Inspector, press … (More) and choose Config bindings….
- Press Unbind on the binding.
- Press Save bindings.
Or right-click the Config row in the Changes tab and choose Unbind. The field becomes a plain value again.
Supported sites
| site | type |
|---|---|
| layout X, Y, width and height of supported built-in widgets | float |
| text auto width | bool |
| comparison operands | int or float |
Hashes, enums, counts and pointers cannot be bound. One setting can drive several sites. A mod can have 32 settings and 256 bound sites. Each bound resource must fit in 64 MiB.
A float keeps its stored unit. The dialog shows the unit of a layout site. One layout pool stores fractions of screen height: Units: fraction of screen height. The other stores unscaled values: Units: unscaled native value.
How it ships
The build writes the bound defaults into your patch and records each site in mod.json. A mod with
bindings uses manifest version 3. At startup, Sunrise writes the saved values into a private copy of
each bound entry. Mods has the loader’s rules.
Limits
- Bindings use the saved settings at the next game start. They do not change package data live.
- The game may still replace a stored default through its own bindings or layout rules.
- Startup
_unp1_packages cannot be bound, because the mod loader cannot replace them. - A source edit that moves a bound row, replaces its target or edits its literal is refused.
- unverified in game.