Module Generator
Generate modules from the Unity editor -- no manual boilerplate. The generator creates the Module Pattern.
Generate Module (Plain C#)
Menu: Pixel Engine / Generate Module
- A dialog prompts for the module name
- Pick a target folder
- Generates
{Name}.cswith the full Module Pattern
What It Creates
A plain C# class implementing the 4-struct architecture:
readonly struct Configuration : IConfigurationwithDefaultfieldreadonly struct Reference : IReferencewithDefaultfieldstruct State : IStatewith public fields (external reads get copy)class Components : IComponents- Backing fields with expression-body properties
SetConfiguration(in Configuration)withinkeyword- Constructor overloads,
Init(),Dispose() - Event placeholders
See Module Pattern for the full generated code.
Generate Module Component (MonoBehaviour)
Menu: Pixel Engine / Generate Module Component
Same flow, but generates the MonoBehaviour variant:
struct Configuration : IConfiguration(not readonly -- Inspector needs mutability)struct Reference : IReference[SerializeField] privateInspector fieldsref readonlyproperty returns for Configuration/ReferenceAwake()->Init(),OnDestroy()->Dispose()- Event placeholders
See Module Pattern for the full generated code.
When to Use Which
| Generate Module | Generate Module Component | |
|---|---|---|
| Use when | Logic-only, no scene presence | Needs Inspector, lives on a GameObject |
| Lifecycle | Manual Init() / Dispose() |
Awake() / OnDestroy() |
| Config/Ref | readonly struct, constructor-injected, in keyword |
struct, [SerializeField] private, ref readonly |
Programmatic Usage
The generator is a static class you can call from your own editor tools:
using PixelEngine.Editor;
// Generate a plain C# module
ModuleGenerator.GenerateModule("WeaponSystem", "Assets/Scripts/Runtime/");
// Generate a MonoBehaviour module
ModuleGenerator.GenerateModuleComponent("WeaponSystemComponent", "Assets/Scripts/Runtime/");
See Also
- Module Pattern -- full pattern documentation
- Script Templates -- Create menu alternative
- Tools Overview -- all available tools