TerraForge — safe cloning of the New World preset UI
✅ Reproduced 🧪 Case study WorldBox 0.51.2
TerraForge needed to append its own generator preset to the vanilla New World preset grid without replacing vanilla presets.
The final UI result looked simple: one extra preset cell.
Getting there was not simple.
Discovery sequence
Section titled “Discovery sequence”The investigation went through several failed assumptions:
- search for a likely
Contentcontainer; - geometry-based detection;
- wrapper-aware scanning;
- runtime logging of button parents;
- discovery of the exact active parent named
Gridcontaining 16 direct buttons.
That final observation gave TerraForge a stable target for appending a 17th cell.
The unsafe approach
Section titled “The unsafe approach”The first direct implementation cloned an active vanilla preset cell.
During Instantiate, the copied ButtonClickMaptemplate component ran its Unity lifecycle and failed inside ButtonClickMaptemplate.Awake() with a NullReferenceException.
Even after injection, the copied EventTrigger still referenced vanilla tooltip behavior and could later call a broken showTooltip() path.
Lesson
Section titled “Lesson”A Unity object can look like a reusable visual prefab while containing behaviors that assume they are being initialized in a very specific vanilla context.
Copying the GameObject copies those assumptions too.
The working pattern
Section titled “The working pattern”TerraForge’s safer route was:
- temporarily deactivate the source vanilla cell;
- instantiate the clone while the source is inactive;
- remove the cloned
ButtonClickMaptemplate; - remove the copied
EventTrigger; - preserve the visual
Button, images, and layout components; - install TerraForge’s own click handler;
- let an already initialized vanilla preset button continue the normal generation flow;
- activate the safe clone.
This produced the custom 17th preset without the earlier Awake() and tooltip crashes.
General rule
Section titled “General rule”When cloning vanilla UI, separate visual structure from behavioral components.
Do not assume that a vanilla MonoBehaviour is safe to duplicate simply because the original object is already working on screen.
What remains version-specific
Section titled “What remains version-specific”The exact object names, hierarchy, and component set are version-sensitive. The pattern is reusable; the literal Grid = 16 buttons observation is verified only for the tested WorldBox build.