Vixen
02b45cc4
csharp
public static class ScriptCompiler

The C# compiler, pointed at a project's own editor scripts.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Doc 36 § P5, and Unity's headline workflow. Code under a project's Editor/ folder is compiled into an editor-only assembly and is not part of what a build ships. It is a convention with a compilation consequence, which is what makes "just write a script" work at all.

⚠ In process rather than dotnet build, unlike the game code beside it. ProjectAssemblies shells out because a game's .csproj is a real project with a restore, an SDK and package references that only MSBuild knows how to resolve. An Editor/ folder is a pile of .cs files with no project file, referencing exactly what the running editor has loaded — so there is nothing for MSBuild to work out, and a second process per keystroke would make the loop useless.

⚠ The references are the host's loaded assemblies, snapshotted. That is a wider set than a .csproj would name, and deliberately: a script author has no project file to add a reference to, so what they can call is what the editor is running. The consequence is that a script can break when the editor loads a panel it had not loaded before — which is why the set is taken once per build rather than per file, so at least one build is self-consistent.

Fields and properties (2)

  • public const string AssemblyName

    What a project's editor-only assembly is called.

  • public const string FolderName

    The folder a project keeps its editor scripts in.

Methods (2)

  • public static IReadOnlyList<string> Sources(string projectRoot)

    Every editor script in a project, in a stable order.

  • public static ScriptBuild Compile(string projectRoot, string output)

    Compiles a project's editor scripts into an assembly beside its library.

Used by (2)

  • EditorScriptsVixen.Editor.Scripts
  • ScriptsModuleVixen.Editor.Scripts