UGTK / Toolkit / Utility Systems / Code Wizard Completed
Code Wizard
Summary
An editor window (UGTK > Code Wizard) that generates C# scripts from configurable templates — raw class, MonoBehaviour, UGTK Singleton, and SO dictionary/simple/randomic databases — defining types and members visually, then tracks, regenerates (region-patched) and deletes the generated files.
Content
Modules Dependencies
This module is self-contained editor tooling. Some built-in templates emit code that references UGTK systems (the Singleton pattern and the ScriptableObject dictionary/database systems), so the generated scripts assume those UGTK systems are present in the project. The wizard itself has no hard runtime UGTK dependency.
Setup
This is an editor-only tool (#if UNITY_EDITOR); no scene setup is required. Open it via UGTK > Code Wizard. Its configuration is persisted in a CWProjectAsset ScriptableObject, and generated scripts go by default under Assets/UGTK/Generated/CodeWizard (configurable in the Settings tab).
How To Use
The window has three tabs:
- Create: pick a template (Raw class, Raw MonoBehaviour, Singleton, SO Dictionary, SO Simple Database, SO Randomic Database), set the type name, namespace, kind (Class / StaticClass / Struct / Enum / MonoBehaviour), inheritance and generics, then add members — fields, properties, methods (with parameters and body), UnityEvents, or enum values — each with visibility and modifiers. Generate to emit the
.csfile. - Scripts: browse the files tracked in the project, regenerate them (user code inside preserved regions is kept via region patching), or delete them.
- Settings: configure the output root folder and default namespace; the hamburger menu also offers Ping Project Asset, Open Output Folder, and Validate Project.
Testing Scene
This is an editor tool: there is nothing to play. Open UGTK > Code Wizard and stay on the Create tab, where the Type Builder puts a whole type together field by field.
What to do, in order:
- Give the type a name and press + Field, + Property, + Method: each one adds a row
with its own access modifier, type and options - a property shows its
getandsetticks. - Press Generate .cs and check the file lands in the output folder shown top right.
- Generate a type from each template.
- Add a member to a generated type and regenerate it.
- Write your own code outside the AUTO region and regenerate again.
- Adopt a hand-written script, then try to delete a file that has no AUTO region.
Step 5 is the guarantee the whole tool rests on: only the text between the markers is rewritten, so your code survives. Step 6 is the other side — the deleter refuses files it did not generate, which is what stops it eating something you wrote.
Technical Info
- CodeWizardWindow: The
EditorWindow(menuUGTK/Code Wizard) hosting the Create / Scripts / Settings tabs and the hamburger actions. - CWProject / CWProjectAsset: Serializable project settings (output folder, default namespace, list of generated file records), persisted as a ScriptableObject.
- CWDefinitions: Data model for a type and its members (
CWTypeDefinition,CWMemberDefinition,CWParameterDefinition, and theCWTypeKind/CWVisibility/CWMemberKind/CWCommonTypeenums). - CWCreateTab / CWScriptsTab / CWSettingsTab: The three tab UIs.
- Templates (
CWDefaultTemplate,CWRawTemplate,CWRawMonobehaviourTemplate,CWSingletonTemplate,CWSODictionaryTemplate,CWSOSimpleDatabaseTemplate,CWSORandomicDatabaseTemplate,CWTemplateRegistry,CWBuiltinTemplateIds,ICodeWizardTemplateProvider,CWTemplateRules,CWFileComposer): the pluggable template system. - Generation (
CWGenerator,CWCodeEmit,CWRegionPatcher,CWScriptDeleter,CWGeneratedFiles,CWGeneratedScriptInfo,CWGeneratedScriptScanner,CWExternalScriptAdopter): code emission, region-preserving regeneration, deletion, and tracking/adoption of generated scripts. - Utils / Validation (
CWPathUtil,CWTypeCacheUtility,CWTypeNameUtil,CWVisibilityUtil,CWValidator): path helpers, type-cache warmup, name/visibility helpers, and project validation.
© 2026 Marcello De Bonis. All rights reserved
Depends on 3
Used by 0
- No other module depends on it.
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 5 modules in total.
UGTKengine within an engine


