Unity Construction Scripts

Unreal Engine has a convenient feature known as “Construction Scripts”: simple scripts that run when an Actor is modified, letting you quickly procedurally generate an object and see the results immediately in the editor.

Unity has a similar feature, ExecuteInEditMode, but it comes with a number of downsides:

  1. Changes made to objects in the scene are saved to the scene file, generating nasty merge conflicts when two people modify the same scene, even if they don’t touch the generated objects.

  2. ExecuteInEditMode can be dangerous — it’s easy to accidentally delete / modify the rest of the scene unintentionally.

  3. For one-off objects, ExecuteInEditMode requires a ton of boilerplate, with careful coding.

Unity Construction Scripts is a simple system which fixes these issues, and makes it quick to write small one-off procedural objects. On top of this, a ConstructionScript is entirely Editor-only. All changes are baked into the scene file just before building the standalone player.

Documentation is provided in the code for now, but feel free to reach out on Twitter if you have questions.