Table of Contents

Script Templates

Canonical source. Unity Script Templates auto-generate the Module Pattern boilerplate from the Create menu.


Available Templates

Template File Menu Path Generates
81a-C# Module-NewModule.cs.txt Create > C# Module Plain C# module (Module Pattern)
81b-C# Module Component-NewModuleComponent.cs.txt Create > C# Module Component MonoBehaviour module (Module Pattern)

Both templates generate the full 4-struct architecture. See Module Pattern for complete code examples and rules.


Key Differences Between Templates

Module Template (Plain C#) Module Component Template (MonoBehaviour)
Config/Ref type readonly struct struct (Inspector needs mutability)
Config/Ref fields { get; private set; } (constructor-injected) [SerializeField] private + ref readonly return
SetConfiguration SetConfiguration(in Configuration) N/A (Inspector-driven)
State/Components { get; private set; } { get; private set; }
Lifecycle Manual Init() / Dispose() Awake() / OnDestroy()
Base IDisposable MonoBehaviour, IDisposable
Events event Action / event Action<T> event Action / event Action<T>
Update() None -- event-driven None -- event-driven

How Script Templates Work

Detail Value
Location Assets/ScriptTemplates/
Naming convention {priority}{id}-{MenuPath}-{DefaultFileName}.cs.txt
#SCRIPTNAME# Replaced with the filename you type in the Create dialog
Restart required Unity must be restarted after adding/changing templates
Priority 81 Places templates near the bottom of the Create menu

Installation

Templates are installed by the package setup tool:

Menu: Pixel Engine / Install Script Templates (or Pixel Engine / Setup All)

After installation, restart Unity for the templates to appear in the Create menu.


See Also