public sealed class EditorScriptsA project's Editor/ folder, compiled and loaded like a plugin.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Doc 36 § P5, and Unity's headline workflow. Drop a .cs file into a project's Editor/ folder, and its menu item is there without restarting the editor. A compile error is a list somebody can read, not a crash and not a silence.
⚠ A script is a plugin, and that is the whole design. The compiled assembly goes into a PluginLoadContext and through PluginHost.Activate, so it gets the registration scope, the rollback-on-throw, the diagnostics, the plugin manager's row and the unload that a plugin dropped in a folder gets. A script host that reimplemented any of those would be a second answer to a question that already has one — and the one it would get wrong is the unload, which is where every leak in this part of the editor lives.
⚠ One assembly for the whole folder, not one per file. Scripts refer to each other — a menu item calls a helper in the file next to it — and a compilation unit per file would make that impossible for no gain. It also means one build, one unload and one reload: a save rebuilds everything, which for a folder of a dozen files is tens of milliseconds.
⚠ A failed build leaves the previous one loaded, deliberately. Somebody halfway through typing a method name should not lose the menu they were about to use. What they get is the errors and the editor they had; what they must not get is an editor whose tools silently vanished because of a missing semicolon.
Fields and properties (3)
public const string PluginIdThe id the plugin host holds a project's scripts under.
public const string PluginNameWhat a plugin-management panel calls them.
public ScriptState StateWhat the last build produced, and what it loaded.
Events (1)
public Action<ScriptState>? RebuiltRaised after every build, whether or not it produced anything.
Methods (3)
public EditorScripts(PluginHost host, string projectRoot, string output)Watches one project's editor scripts.
public ScriptState Rebuild()Compiles the project's editor scripts and loads what came out.
public bool Unload()Takes the scripts back out, if any are loaded.
Used by (2)
- EditorScriptTestsVixen.Editor.Scripts.Tests
- ScriptsModuleVixen.Editor.Scripts