Skip to content

Clone vanilla UI more safely

🧪 Reproduced case studyTerraForgeWorldBox 0.51.2

This is not a beginner first-mod recipe and not a universal prefab-cloning API. Use it when you have already identified a specific vanilla UI object and need to reuse its visual hierarchy without blindly re-running copied behavior components.

A vanilla UI object may look like a reusable visual prefab while carrying MonoBehaviour components that assume a very specific vanilla initialization context.

TerraForge cloned an active vanilla New World preset cell. The copied ButtonClickMaptemplate ran Awake() during Instantiate and threw NullReferenceException. A copied EventTrigger also retained unsafe vanilla tooltip behavior.

Safer pattern that worked in the case study

Section titled “Safer pattern that worked in the case study”
1. temporarily deactivate the source vanilla cell
2. instantiate the clone while the source is inactive
3. remove copied ButtonClickMaptemplate
4. remove copied EventTrigger
5. keep visual Button / Image / layout components
6. attach your own click handler
7. use an already initialized vanilla path where needed
8. activate the cleaned clone

Treat visual structure and behavioral components as separate things.

Do not assume copying a working GameObject means every copied component is safe to initialize again.

The reusable lesson is the lifecycle pattern. The exact hierarchy, component names and “16 vanilla buttons in Grid” observation are version-specific to the tested WorldBox build.

Open the full TerraForge case study for the discovery sequence.