Plugins — Runtime, Assets and Editor Packages
A Stride plugin extends the engine with runtime types (components, content) and, on the tooling side, with asset types, compilers, templates and Game Studio pieces (icons, gizmos, previews). It ships as a runtime package and up to two companion packages that the tools load on the runtime's behalf. A game references the runtime only.
| Package | Kind | Contains | Loaded by |
|---|---|---|---|
MyPlugin |
Runtime | components, scripts, content types | the game, the asset compiler, Game Studio |
MyPlugin.Assets |
Assets |
asset classes, compilers, importers, asset templates, icons, static thumbnails | the asset compiler, Game Studio |
MyPlugin.Editor |
Editor |
plugin class, gizmos, previews, thumbnails | Game Studio only |
The engine's own optional packages follow the same shape: Stride.Physics declares Stride.Physics.Assets and Stride.Physics.Editor, Stride.Audio declares Stride.Audio.Assets and Stride.Audio.Editor, and so on. All the projects of a plugin (runtime, Assets, Editor, Editor.Wpf and tests) live together in sources/plugins/<Name>/: sources/plugins/Audio/ holds Stride.Audio, Stride.Audio.Assets, Stride.Audio.Editor, Stride.Audio.Editor.Wpf and Stride.Audio.Tests. The folder names the plugin, not always its projects: the Bullet physics plugin keeps its Stride.Physics project and assembly names in sources/plugins/BulletPhysics/ (with Stride.Navigation, which builds on it), beside sources/plugins/BepuPhysics/.
Declaring the packages
A companion states what it carries with StridePackageKind (which also makes it host-loadable):
<!-- MyPlugin.Assets.csproj -->
<PropertyGroup>
<StridePackageKind>Assets</StridePackageKind>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Stride.Core.Assets" Version="4.5.0" />
<PackageReference Include="Stride.AssetCompiler" Version="4.5.0" IncludeAssets="build;buildTransitive" />
<ProjectReference Include="..\MyPlugin\MyPlugin.csproj" />
</ItemGroup>
The runtime lists its companions. By project, when they are built together:
<!-- MyPlugin.csproj -->
<ItemGroup>
<StrideCompanionProject Include="..\MyPlugin.Assets\MyPlugin.Assets.csproj" />
<StrideCompanionProject Include="..\MyPlugin.Editor\MyPlugin.Editor.csproj" />
</ItemGroup>
or by package, when a companion comes from a feed:
<ItemGroup>
<StrideCompanionPackage Include="MyPlugin.Editor" Version="1.2.0" Kind="Editor" />
</ItemGroup>
The companion's package id, version and kind are read from the companion project at build and pack time, so the runtime's packed .sdpkg records exactly what was packed. The three packages are packed separately (dotnet pack each project); a companion's version must equal the one the runtime recorded, so publish all three together.
An Editor package records the UI toolkit it is built for (StrideEditorToolkit): Wpf (Game Studio) or Avalonia (the cross-platform editor). An editor loads the Editor packages of its own toolkit only, whether they come from a feed or from the solution, and every editor loads the toolkit-neutral ones. The build infers the toolkit from the package's direct references:
Wpf: the package references a*.Wpfproject or package, or uses WPF itself (UseWPF);Avalonia: the package references a*.Avaloniaproject or package, or Avalonia itself (theAvaloniapackage or anAvalonia.*one);- neutral: it references neither.
A package that gets a toolkit only through another plugin's Editor package sets it itself (<StrideEditorToolkit>Wpf</StrideEditorToolkit>), and an explicit StrideEditorToolkit always wins over the references. A package that references both toolkits fails the build, naming the references that brought in each: no editor would load it, so keep it neutral and split its views into one companion per toolkit. The build warns about any toolkit other than Wpf and Avalonia, since no editor would load the package.
The plugin, view model, gizmo, entity factory and preview base classes live in the toolkit-neutral editor assemblies (Stride.Assets.Editor and what it references), so an Editor package that references those only is neutral, and any editor loads it. Keep views in a package of their own per toolkit, which the neutral Editor package declares as its companion: Stride.Audio.Editor declares Stride.Audio.Editor.Wpf, which holds the sound preview's view, Stride.SpriteStudio.Editor declares Stride.SpriteStudio.Editor.Wpf, which holds the sheet preview's view, and Stride.UI.Editor (still Wpf itself until the UI editor is ported) declares Stride.UI.Editor.Wpf, which holds the UI editors' views and property templates. The Avalonia views will sit next to them in .Avalonia companions (e.g. Stride.Audio.Editor.Avalonia), declared by the same neutral package; the WPF editor skips those and the Avalonia editor skips the .Wpf ones. The types of an .Avalonia companion go in its own namespace (Stride.Audio.Editor.Avalonia, Stride.UI.Editor.Avalonia.Views), so that no view has the full name of its WPF counterpart, and a test or tool can reference both. Such a package has its own StrideAssetsPlugin subclass, since a plugin registers the views of its own assembly only; a subclass that reads WPF resource dictionaries derives from StrideAssetsWpfPlugin. A companion from a feed carries the toolkit as Toolkit="Wpf" or Toolkit="Avalonia" metadata.
Replaces="a;b" on either item names companion packages declared elsewhere that this one stands in for. A game can declare its own StrideCompanionProject with Replaces="MyPlugin.Assets" to substitute a plugin's Assets companion by a project of its own.
How the tools find them
- Asset compiler (game build): loads the
Assetscompanions declared by every package in the session, at the recorded version: a project already in the session, else the local dev store, else an exact NuGet restore with the game's NuGet configuration. Editor companions are never loaded. - Game Studio: the same, plus the
Editorcompanions. A companion project in the solution is used as is, compiled on load and rebuilt on edits.
A game must not reference a companion package directly (a warning says so): the runtime's declaration is the only thing that keeps versions consistent.
Plugin in the game's solution
The plugin's three projects can live in the game's solution as source. The game references the runtime project only:
<ProjectReference Include="..\MyPlugin\MyPlugin.csproj" />
The game's executable project builds the Assets companions declared along its project references and lists their build manifests in its own, so the asset compiler finds them without any restore and the game output never ships them. A companion that no project references is restored by the runtime project's build the first time. The Editor companions are not built by the game: Game Studio compiles them from the solution. On Linux and macOS, a game build leaves out a companion that targets Windows only (a .Wpf view package, or an Editor package that still uses WPF) instead of restoring it, since no host there loads it; a toolkit-neutral Editor package targets net10.0 ($(StrideXplatEditorTargetFramework) in the engine) and is restored like any other.
Creating a plugin
- Game Studio: Plugin in the session's New project list. Asks for the name and, when several game libraries own a
GameSettingsasset, which one references the plugin (the current project's game is proposed first). The three projects join the solution and the chosen game library gets theProjectReference. Plugin in the startup dialog creates a solution holding only the plugin, named after it: asset editing works there (the editor's own default settings and preview compositors), there is just no game to run. - Command line: with the
strideCLI or adotnet newinstall ofStride.Templates.Games:dotnet new stride-plugin -n MyPlugin -o MyPlugin dotnet sln MyGame.slnx add MyPlugin/MyPlugin/MyPlugin.csproj MyPlugin/MyPlugin.Assets/MyPlugin.Assets.csproj MyPlugin/MyPlugin.Editor/MyPlugin.Editor.csproj dotnet add MyGame.Game reference MyPlugin/MyPlugin/MyPlugin.csproj
The name can be dotted, as NuGet package ids usually are: Acme.Fog gives the projects Acme.Fog, Acme.Fog.Assets and Acme.Fog.Editor and the namespace Acme.Fog, while the types and the asset file extension take the last segment (FogComponent, FogAsset, .sdfog).
The template's content is small but complete: a component and a content type (runtime), an asset with its compiler, its asset template and the component's icon (Assets), the plugin class with a gizmo (Editor). The template source is samples/Plugin/Plugin.
Building and packing
- Platform: a plugin's projects target
net10.0without a runtime identifier. Stride's targets give such a project the platform of the machine that builds it: Windows on Windows, Linux on Linux, macOS on macOS. A library or test project built on Linux or macOS then gets the VulkanStride.Graphics, as the game's Linux and macOS heads do. Awin-*runtime identifier or a Windows target framework (net10.0-windows) still gives Windows. - Version: each package's packed
.sdpkgstates the version of its NuGet package (PackageVersion, fromVersion), sodotnet pack -p:Version=1.2.0packs the three packages, and the companions the runtime records, with that version. - Property descriptions: a project that makes an XML documentation file (
GenerateDocumentationFile) also gets<AssemblyName>.usrdocbeside its assembly, the<userdoc>descriptions of its members that Game Studio shows in the property grid. Its package carries the file beside the assembly.
Writing the pieces
Asset classes, compilers and importers: see the asset system documentation; nothing is plugin-specific, the
Assetspackage is discovered like an engine assembly.Asset references in compiled content: the build adds to the game the assets that an asset references at runtime (a texture, a model, another asset of the plugin) only inside the types its compiler returns from
GetRuntimeTypes. A compiler whose asset references other assets returns the asset type, or the types of its members that hold the references (the template's compiler returns its asset type). Without it, the game build fails at the bundle step with Could not find content [Textures/Wood], referenced by [MyAsset], naming the referenced and the referencing content.Build commands: the commands a compiler schedules (
AssetCommand<T>) are data contracts, as every command of the build engine is, but a command is serialized only when it runs in a process of its own (it overridesShouldSpawnNewProcessto returntrue). The serialization analyzer asks for a public parameterless constructor (STRDIAG010) of such a command only; a command that runs in the compiler's process, as the template's does, needs none.Shipped assets: the assets a plugin ships (default content, a library, the source files they are built from) go in the
Assetspackage, under the folders its.sdpkglists inAssetFoldersandResourceFolders. The asset compiler and Game Studio load it with the runtime, and a reference by id finds an asset in any package of the game's dependencies, companions included. An asset the runtime loads by URL goes in the.sdpkg'sRootAssets: the root assets of every package a game depends on are compiled into it.Asset URL constants: the runtime declares each asset file extension of its
Assetspackage with the type the compiled content loads as,[assembly: AssetFileExtension(".sdmyasset", typeof(MyContent))], so a game gets typed constants for those assets. Only.sd*files get constants. A build warning (STRDIAG014) points at an asset type whose extension no runtime declares. A file whose extension nothing declares gets no constant, except the asset types that left the engine for a plugin in 4.5 (.sdvid,.sdsnd,.sduipage, ...): those keep an untyped constant, and a warning (STRDIAG015) names the package to reference for the typed one.Game systems: a runtime class marked
[GameSystem](aGameSystemBasewith anIServiceRegistryconstructor) is created by every game and registered as a service, in assembly then type name order. Only an assembly registered when the game is created counts, so the game must reference the plugin's package or project directly: a plugin it only gets through another package is not registered, and its game systems are not created (Add dependency offers such a package, marked "already available"). The editor's games (scene, prefab and preview games) skip it unless it asks for it with[GameSystem(Editor = true)], as the audio system does.Icons and static thumbnails:
[assembly: TypeImage(typeof(MyComponent), "MyComponent.png")]over an embedded resource of the declaring assembly, images of enum values[assembly: EnumImage(MyEnum.Value, "Value.png")]and static thumbnails[assembly: StaticThumbnail(typeof(MyAsset), "MyThumbnail.png")]the same way. They are plain data (Stride.Core.Assets.Editor.Annotations, inStride.Core.Assets), so theAssetspackage can declare them: a plugin without anEditorpackage still gets its icons, and theEditorpackage may declare them too. Both editors show the images of every registered assembly, for as long as it is registered; an image a plugin registers in code wins over a declared one. An image the editor can't decode (a file that isn't an image, such as a Git LFS pointer that was not pulled) is left out with a warning in the load log and an error of the plugin (or of its assembly) in the Plugins panel; the project still opens.Game Studio extensions: a
StrideAssetsPluginsubclass in theEditorpackage is the entry point. An empty class is enough: what the assembly declares with attributes (asset view models, editors, previews, gizmos, scene view tools, settings, images) is found without it doing anything. To register more, override the two methods of the plugin context, calling the base method first:Initialize(IEditorPluginContext context), once per editor: images (context.TypeImages,context.EnumImages), primitive types, template providers, copy and paste processors, scene view tools (context.SceneViewTools(), see Scene and prefab views), settings keys, profile settings, panels and their views, commands and toolbar widgets (see below);InitializeSession(ISessionPluginContext context), once the session is open: services (context.Services, see Services), property grid commands and updaters (context.NodePresenterCommands,context.NodePresenterUpdaters), and withcontext.OnClose(...)what to clean up.
The editor records each registration under the plugin and removes it when the plugin leaves: its assembly is reloaded or unloaded, or the session closes, which also runs the
OnCloseactions, newest first. The olderRegister*methods,InitializePluginandInitializeSession(ISessionViewModel)are obsolete (see Migrating from the older plugin API) but still work, through the base methods: the editor removes what they register too, except the services thatInitializeSession(ISessionViewModel)adds to the session directly and what a plugin keeps in static fields. The template's plugin class shows the two methods. Gizmos[GizmoComponent(typeof(MyComponent), true)]classes, tools of the scene and prefab views[EditorViewTool]classes (Stride.Assets.Editor.AssetEditors.EntityHierarchyEditor.Tools; registered as if the plugin registered them withcontext.SceneViewTools()), previews and their view models by theAssetPreviewattributes. Views are WPF today; keep them in the.Wpfcompanion package so theEditorpackage stays toolkit-neutral (it referencesStride.Assets.Editor, not a*.Wpfassembly). The editor's session, the hierarchy item an entity factory creates for and the editor game controller reach the plugin as interfaces (ISessionViewModel,IEntityHierarchyItemViewModel,IEditorGameControllerand itsIEntityHierarchyEditorController/ISceneEditorControllerrefinements): an editor game service declares the controller interface in its[EditorGameService]attribute and takes it, orIAssetEditorViewModel, in its constructor.Editor settings: a static class marked
[EditorSettings], in the assembly of the plugin class, holds the plugin's settings keys (static fields or properties created inEditorSettings.SettingsContainer). Game Studio registers them with the plugin's assembly and removes them when the assembly is unloaded, so a reloaded assembly (a plugin project of the solution rebuilt, a package removed and added again) creates them again.Stride.UI.Editor'sUIEditorSettingsis declared this way.Asset templates: a
Templates/Assets/*.sdtplin theAssetspackage (!TemplateAssetFactory), listed underTemplateFoldersin the package's.sdpkgnext to the project (the template'sMyPlugin.Assets.sdpkgshows the shape), packed with it. Without that list the asset type never appears in Add asset.Render features: a class implementing
IRenderFeatureProvider(inStride.Assets) in theAssetsorEditorpackage returns the render features the plugin needs, for the opaque and transparent stages it is given. The editor's preview and thumbnail compositors take them at runtime;Stride.SpriteStudio.Editor,Stride.Particles.EditorandStride.UI.Editorwork this way. A game's own compositor asset is the game's: the engine default it derives from carries no plugin feature, so a compositor created in Game Studio gets the features of its project's packages (its dependencies,PackageTypeScope), and for an existing one, once the game references the plugin, Add package features in the compositor editor adds the missing ones (through the property graph, so undo and the dirty flag follow). The engine's compositors carry no particle or UI feature sinceStride.ParticlesandStride.UIbecame plugins; upgrading a game's compositor derived from them keeps each of those features it had, now owned by the game's compositor, or removes it when the game does not reference that plugin.
Services
Game Studio's view models find their services through an IViewModelServiceProvider (Stride.Core.Presentation.ViewModels), which is also a System.IServiceProvider. There are three scopes, each a child of the one before:
- The editor, for the whole process: dialogs, the dispatcher, the plugin service, the clipboard.
- The session, while a project is open: undo and redo (
IUndoRedoService), copy and paste, selection, the asset editors manager, and the services the plugins add withcontext.Services(the asset builder, the game settings, the previews...). It issession.ServiceProvider, and it goes when the session closes. - An asset editor's tab, while the editor is open: empty at first, for the services of that editor.
A scope looks up a service it doesn't have in its parent when the service is asked for, so a service registered later in a parent is seen, and a service of a child hides one of its parent. The editor's scope doesn't see the session's: ask the session (or the asset, or the editor, whose services hold the session's) for a session service.
Registering. In InitializeSession(ISessionPluginContext context), not in Initialize(IEditorPluginContext context), which has no services: it comes before the session's editor is initialized.
context.Services.Register(instance)adds an instance. A lookup of a type gets the one instance assignable to it, and throws when two are.context.Services.Register<TService>(factory, lifetime)adds a service made byfactory(which gets the services of the scope it is made for) under the typeTService: a lookup of exactly that type gets it, even when several instances would also match. WithViewModelServiceLifetime.Singleton(the default) it is made once for the session, the first time it is asked for. WithViewModelServiceLifetime.PerScope, the session and each editor's tab that asks for it get their own instance, which goes with that scope.
What a plugin registers goes when it leaves the session (its assembly is reloaded or unloaded, or the session closes), and the instances its factories made are disposed. Instances registered as such are not: they belong to the plugin.
Constructor injection. The types Game Studio creates for a plugin can take services in their constructor, after the arguments they always get. The longest public constructor whose parameters are those arguments or services is used (ActivatorUtilities, from Microsoft.Extensions.DependencyInjection.Abstractions), so the usual signatures keep working:
- asset editors:
(MyAssetViewModel asset), plus services. An editor that also takes anIViewModelServiceProvidergets the services of its tab; it passes them to the base constructorAssetEditorViewModel(asset, serviceProvider)and can register services of its own there, which go when the editor closes; - the views of the asset editors, the previews, their view models (
(SessionViewModel session), plus services) and their views; - panels, toolbar widgets and command handlers, which the plugin creates from its context with
context.CreateInstance<T>(arguments): the constructor gets the given arguments, the context if it asks for it, and the session's services.
public override void InitializeSession(ISessionPluginContext context)
{
// One for the session, made when first asked for, disposed when the plugin leaves
context.Services.Register<IMyLibraryIndex>(services => new MyLibraryIndex(context.Session));
}
public override void Initialize(IEditorPluginContext context)
{
context.Panels.Register(new PanelDescriptor
{
Id = "MyPlugin.Library",
Title = () => "My library",
// MyLibraryPanelViewModel(PanelContext context, IMyLibraryIndex index, IUndoRedoService undoRedo)
CreateViewModel = panel => panel.CreateInstance<MyLibraryPanelViewModel>(),
});
}
The factory registrations of context.Services and the contexts' CreateInstance are experimental (STREXP006, see Editor versions and experimental API). The editor game of the scene editors keeps its own services (IServiceRegistry, [EditorGameService]), apart from these.
Panels, views and plugin states
These parts of the plugin context are new in the cross-platform Game Studio. The WPF Game Studio accepts them and shows nothing.
- Panels (
context.Panels): aPanelDescriptor(Stride.Core.Assets.Editor.Panels) with an id<plugin>.<name>that never changes once released, a title, a default place and a factory ofIPanelViewModel(derive fromPanelViewModel). The panel is listed in the View menu, a panel withAllowsMultipleInstancesgets a "New" entry, and the layouts remember where it was. The plugin owns it: when the plugin leaves, the panel leaves the View menu, its open instances close, and the saved layout keeps its place for its return. - Views (
context.ViewTypes): the view type of a view model type, in the editor's toolkit. The neutralEditorpackage registers the panel; its toolkit companion (.Avalonia,.Wpf) registers the view, an AvaloniaControlfor the cross-platform editor, created with no argument and given the view model asDataContext. A registration for a base type covers the derived ones. A view model with no view in the running editor shows "No view for this editor", and a warning names the panel and the plugin. - Registries of other layers (
context.GetRegistry<T>()): a layer of the editor declares the registry of its own contribution points (EditorPluginHost.DeclareRegistry<T>()), and usually gives it a typed extension method on the context. A contribution goes with its plugin, as the others. Asking for a registry that no layer of the editor declares throws, so the plugin does not join. - Plugin states and failures: the editor keeps a state per plugin (
EditorPluginHost.PluginStatuses: joined, failed to join, incompatible (see Editor versions and experimental API), off (see Switching a plugin off and safe mode)) with its errors. The editor runs the code of a contribution (a panel's view model, a view) through a guard (IPluginContributionGuard): when it throws, the error is logged with the plugin's name and recorded in its state, that contribution is turned off until the session opens again (a panel leaves the View menu), and the rest of the plugin stays. A plugin that fails to join is left out without what it registered; one whoseInitializeSessionfails stays, with the error recorded.
Switching a plugin off and safe mode
A plugin that breaks Game Studio can be left out without touching the project. Both Game Studios honor what follows; only the cross-platform one shows it, in the Plugins panel and the safe mode banner (see below).
Switched off for a session. The
Editorpackage of a plugin (and its.Avaloniaor.Wpfcompanion with it) can be switched off for one session file. The list is kept per user, in the internal settings of Game Studio (Internal/DisabledEditorCompanionsinGameStudioInternal.conf, one entry per session file with the names of the packages), and applies the next time that session opens. A switched-off package does not load: its asset editors, previews, gizmos, additions to the property grid, panels, commands, tools and widgets of the scene view, and render features go, so what its components draw may no longer show in the scene editor. ItsRuntimeandAssetspackages still load, so its assets open, with the generic property grid.PluginSwitchServicesets and clears an entry and describes what goes (DescribeSwitchOff);PluginCatalog.Collectdescribes each plugin of a session (PluginInfo: its package id, version,.nuspecfields, where it comes from, the editor version it was built against, its contributions per kind and its state).The plugins of Stride can't be switched off. The
Editorpackages of the engine's own plugins (Audio, Particles, Physics, SpriteStudio, UI, Video, Voxels), at the editor's major and minor version, always load (BuiltInPlugins): the editor's scene rendering relies on some of them. An entry that names one is ignored with a warning in the session's log.Safe mode.
--safe-modeon the command line of either Game Studio loads only the plugins of Stride: every otherEditorpackage is off, and a plugin class in any other assembly of the session (the game's own, a package it references) does not join. Those assemblies still load, since the project's assets need their types: safe mode keeps out the plugins, not all the code of the project. A restart (to reload the session, or open another one) keeps it, until Game Studio starts again without it.After a crash while plugins load. Game Studio writes a marker while the plugins join a session (
PluginLoading/<process id>.markerbeside the settings files), and removes it once the session has opened. When Game Studio stopped in between, the next start offers once to start in safe mode, and clears the marker whatever the answer.The Plugins panel (cross-platform Game Studio, View > Plugins, hidden by default): every plugin of the editor and of the session, what needs attention first (failed, incompatible, or with errors), then what is off, the project's plugins and the built-in ones. It shows each one's package id, version, source, kind and toolkit, authors, description, icon and project page from the
.nuspec, the Game Studio version it was built for, its contributions per kind, and its state with the reason. Its errors (joining, loading, a contribution the guard turned off) show with the contribution and the time, and can be copied. A third-party plugin has a switch: switching it off asks first, with what goes; the change applies when the project opens again, and "Restart to apply" opens it again in a new Game Studio after the save question. An entry that names a built-in plugin can be cleared from the panel. The user's extensions show in a group of their own, with Add an extension, a switch for every project and Remove (see Editor extensions).The safe mode banner (cross-platform Game Studio): in safe mode, a banner under the toolbar says how many plugins are off, with "Show the plugins" and "Restart normally" (the same project in a new Game Studio, without
--safe-mode).
A package left out this way has the state off (PluginState.Off, PluginStatus.OffReason says whether it was switched off or Game Studio runs in safe mode; Plugin is null and Name is the package's name), and the session's log says why it is not loaded. PackageSession knows nothing of plugins: the editor gives it a filter (ICompanionPackageFilter, PackageLoadParameters.CompanionPackageFilter) that it asks once per Editor companion of the session's toolkit. A package also reached as a NuGet dependency of another package of the session loads as such, but the plugin classes of a package switched off don't join the session, however their assembly was loaded.
Editor extensions
An extension is an Editor package that a user installs for every project, rather than one a game declares: a tool, a panel or a command that is not tied to one game. Game Studio loads it with every session, as if each project declared it as a companion.
- Shipping one. An extension is an
Editorpackage like the companion of a plugin (<StridePackageKind>Editor</StridePackageKind>, see Declaring the packages), packed withdotnet pack. It is not referenced by a runtime package: there is nothing to declare in a game. Its views go in a toolkit companion that it declares (.Avalonia,.Wpf), packed with it; a package it depends on (aPackageReference) is restored with it. Its plugin class registers what any plugin registers (InitializeandInitializeSession), with the same rules: experimental areas, version check, contribution guard. - Installing it. In the cross-platform Game Studio, the Plugins panel's Add an extension takes a
.nupkgfile, or a folder of packages (whatdotnet packwrites: eachEditorpackage of the folder that no other package of the folder declares as a companion is an extension, at its highest version). Game Studio copies the package, its companions and the dependencies found in the same folder into a local feed of the user (Extensions/<major>.<minor>/beside the settings files), and the session restores from that feed and the configured NuGet sources (NuGet has no order between them). A package of another kind, anEditorpackage of the other toolkit, and the engine's own plugins are refused with a message. Another build with the same version replaces the one restored before. The restored package must be the file in the feed (the hash NuGet keeps in its global packages folder): when another source served a package with the same id and version, the extension is not loaded, and the Plugins panel shows it as failed, with the reason in the project's load log. - Per editor version. The list is kept per user and per major.minor version of Game Studio, in the internal settings (
Internal/EditorExtensionsinGameStudioInternal.conf: each entry has the package id, version, toolkit and whether it is switched off). An extension installed for 4.5 is not loaded by 4.6; install it again there. An extension built against a newer Game Studio is refused by the version check as any plugin (see Editor versions and experimental API). - When it applies. The session reads the list when it opens: what is added, switched off or removed applies when Game Studio opens a project again ("Restart to apply" in the Plugins panel).
- Switching it off and removing it. An extension's switch in the Plugins panel applies to every project; it stays installed. Remove takes it out of the list and its packages out of the feed. Safe mode leaves the extensions out with the other third-party plugins.
- When the project has it too. A project that declares the same package as a companion, or has it in its solution, keeps its own: the extension is not loaded for that project ("Off: in the project").
- The WPF Game Studio loads the extensions of its toolkit that the list names, with the same rules, and has no panel to manage them.
- What an extension can't do. It loads with a session: it can't add to the start screen (the recent projects and the new project dialog), which shows before any session opens.
PackageSession knows nothing of extensions: the editor gives it a source of companion packages (ICompanionPackageSource, PackageLoadParameters.CompanionPackageSource) that names the packages to add to every session and the feeds to restore them from, and checks each package once restored (IsRestoredPackageExpected). The session asks the companion filter for each one, with no declaring package (ICompanionPackageFilter.ShouldLoad(null, ...)), and keeps what it read (SourceCompanionPackages) and what it loaded (LoadedSourceCompanionPackages). EditorExtensionService installs, lists, switches off and removes the extensions; PluginCatalog lists them with PluginSource.Extension.
Commands, menus and toolbars
Like panels, these parts of the plugin context are shown by the cross-platform Game Studio only. The WPF Game Studio accepts them and shows nothing.
- Commands (
context.Commands): aCommandDescriptor(Stride.Core.Assets.Editor.Commands) with an id<plugin>.<name>that never changes once released (the user's shortcuts refer to it), a title (and, if it depends on what the command acts on, a title in context), an optional icon, an optional default shortcut,ExecuteAsync, an optionalCanExecute, and its placements. A placement names a location, an optional group and an order: the built-in menus keep their own items and show the commands of their location at their end (before Exit in the File menu), after a separator, a group between separators, the groups by their lowest order.CommandLocationslists the editor's locations: the end of the File, Edit, View, Project and Help menus, a Tools menu (shown only when it has commands), the main toolbar after the build buttons, and the context menus of the asset view, the solution explorer and a property of the property grid. The scene and prefab editors add theirs inStride.Assets.Editor.Commands.SceneLocations(the entity tree's context menu). A command with no placement is reached by its shortcut and the command palette only. - The command registry:
context.Commandsis the registry of every command of the editor, its own included. The main menu and the main window's shortcuts are commands that the editor's plugins register, each running the editor's existing command:Stride.File.*,Stride.Edit.*,Stride.View.ResetLayout,Stride.Project.*,Stride.Help.*and the asset view'sStride.Asset.*(listed below; the shared ids are constants ofSessionCommands). They have no placement: the main menu's items and the main toolbar's buttons refer to them by id (Command="{cmd:Command Stride.File.Save}",xmlns:cmd="using:Stride.Core.Assets.Editor.Avalonia.Commands"), and show their title (unless the item has a header of its own, for its access key), the user's shortcut and their state; a toggle shows a check. The editor's context menus do the same with their own items (see Context menus and editor shortcuts). The View menu's panels are toggles too (<panel id>.Toggle, such asStride.AssetView.ToggleorMyPlugin.Library.Toggle, registered by the editor for each single-instance panel). New, Open, Exit, the Help commands and the command palette also work without a session (in the project selection window, with the user's shortcuts). - Categories, keywords and the palette:
Category(one ofCommandCategories: File, Edit, View, Project, Asset, Scene, Tools, Help, or a name of the plugin's own) andKeywordsare what the command palette and the list of shortcuts show and search, besides the title. Every command is in the palette unlessShowInPaletteis false (a command that only makes sense where it is placed, such as one acting on the property a context menu opened on). The palette runs a command withCommandContext.ForPalette: the locationCommandLocations.Palette, the asset view's selected assets and folders asSelection(even when an editor has the focus), and the editor that had the focus asEditor. - Toggles: a command that turns something on and off gives
IsChecked; its menu items show a check. - What a command acts on (
CommandContext): the session, the location it was invoked from (CommandLocations.Shortcutfor its shortcut,CommandLocations.Palettefor the palette), the selection of that place (the assets of the asset view, the items of the solution explorer, the property's node, the entities of the tree; the asset view's selection for the palette; none for a shortcut), the asset editor it was invoked in (Editor: the one whose context menu opened, or that had the focus when the key was pressed or the palette opened; null elsewhere) and, for a command that comes with a view of the same toolkit, the toolkit element it was invoked from (Source; for a shortcut, the control the key was pressed on). - Shortcuts: a default shortcut is written "Ctrl+Shift+K" (
CommandGesture), in any order and case. A plugin's needs Ctrl, Alt or Meta, unless its key is a function key (F1 to F24), so that text boxes keep their keys. Shortcuts are claimed in three layers (CommandGestureBindings): first the user's, then the defaults of the editor's own commands (those of its own assemblies), then the plugins' defaults, each layer in registration order. A command whose shortcut is taken, has no such modifier, or is not a shortcut, is not bound: the conflict is listed (CommandGestureBindings.Conflicts: who loses, why, and who keeps the shortcut) and logged as a warning. Shortcuts run after the focused control has seen the key, in the main window and in the floating windows. - Gesture scopes:
GestureScopeis null for a shortcut of the main window, or the type of an asset editor's view model (the scene editor's, for instance) for one that works only while the focus is in an editor of that type, which the command gets asCommandContext.Editor. There it goes before a main window shortcut with the same keys; a plugin's default shortcut in an editor can't take one the main window binds, though (the user's can). A shortcut with no Ctrl, Alt or Meta on a key that types a character (the scene editor's F) doesn't run while the focus is in a text box. - The command palette (
Stride.View.CommandPalette, Ctrl+Shift+P, also in the View menu): a search box over the main window that lists the commands of the palette, the recently used ones first (Internal/Avalonia/RecentCommands), then those that can run now. Every word typed must be in the title, the category or a keyword of a command. Each line shows the category, the title, the shortcut and, for a toggle, its check; Up, Down, Page Up and Page Down move, Enter or a click runs the command, Escape closes. The palette runs it withCommandContext.ForPalette, with the control that last had the focus asSource, so that the Edit commands act where the user was. - The Keyboard shortcuts page (
Stride.Edit.KeyboardShortcuts, Edit > Keyboard shortcuts, a page of the Settings window): every command with its category and shortcut, searched by title, category, id, shortcut or keyword. A shortcut is recorded by pressing it in the box below the list (with Ctrl, Alt or Meta, unless its key is a function key or the command's own default); None removes it, Reset gives back the default, and Reset all gives back every default. A shortcut the user changed is in bold, and a conflict shows on the lines of both commands. The changes are saved, and the menus and shortcuts follow, when the Settings window is closed with "Save and close"; Cancel drops them. - The user's shortcuts: the settings key
Shortcuts/Overridesof GameStudioSettings.conf maps a command id to a shortcut, or toNone(or nothing) to remove the command's:Stride.File.Save: Ctrl+Alt+S. They come before every default; an id that no loaded command has is skipped. The Keyboard shortcuts page writes them; only the cross-platform Game Studio reads them. - Toolbar widgets (
context.ToolbarWidgets): aToolbarWidgetDescriptorwith an id, an order and a factory of a view model (anIDestroyable), shown after the command buttons with the view that the toolkit companion registers incontext.ViewTypes. The view model is destroyed when the session closes or the plugin leaves. - Failures: the editor runs a command's title in context,
CanExecute,IsCheckedandExecuteAsync, and a widget's view model and view, through the contribution guard: one that throws is turned off for the session (it leaves the menus, the toolbar and the shortcuts), the error is logged with the plugin's name and recorded in its state, and the rest of the plugin stays.
The editor's own commands, with their default shortcuts (Ctrl is Cmd on macOS):
| Category | Commands |
|---|---|
| File | Stride.File.New (Ctrl+N), Stride.File.Open (Ctrl+O), Stride.File.Close, Stride.File.ClearRecent, Stride.File.Save (Ctrl+S), Stride.File.ReloadProject, Stride.File.Exit (Alt+F4) |
| Edit | Stride.Edit.Undo (Ctrl+Z), Stride.Edit.Redo (Ctrl+Y), Stride.Edit.Cut (Ctrl+X), Stride.Edit.Copy (Ctrl+C), Stride.Edit.Paste (Ctrl+V), Stride.Edit.Delete (Delete), Stride.Edit.Rename (F2), Stride.Edit.PreviousSelection (Alt+Left), Stride.Edit.NextSelection (Alt+Right), Stride.Edit.Settings, Stride.Edit.KeyboardShortcuts |
| View | Stride.View.ResetLayout, Stride.View.CommandPalette (Ctrl+Shift+P), <panel id>.Toggle (one per panel of the View menu, in the panel's namespace) |
| Project | Stride.Project.Build (F6), Stride.Project.Start (F5), Stride.Project.CancelBuild (Ctrl+F6), Stride.Project.AddDependency, Stride.Project.OpenInIDE, Stride.Project.ReloadGameAssemblies |
| Asset | Stride.Asset.EditSelected (Ctrl+Enter), Stride.Asset.Add (Ctrl+I), Stride.Asset.CopyRecursively (Ctrl+Shift+C), Stride.Asset.UpdateSelectedFromSource (Ctrl+Shift+R), Stride.Asset.UpdateAllFromSource (Ctrl+R), and those of the context menus below |
| Help | Stride.Help.Documentation, Stride.Help.Questions, Stride.Help.ReportIssue, Stride.Help.Forum, Stride.Help.DebugWindow (Ctrl+Shift+D), Stride.Help.About |
The Edit commands act on the control that last had the focus in the window they come from, like the Edit menu. The platform's other Edit keys (such as Ctrl+Shift+Z, Ctrl+Insert, Shift+Insert and Shift+Delete) still run Redo, Copy, Paste and Cut after the commands' shortcuts; they are not commands and can't be changed. The scene editor's tool and camera keys (W, E, R, the camera's WASD) are the editor game's input, not commands: they stay in the scene editor's settings.
The editor's own first command is the nested properties toggle, in the context menu of a property: "Expand all nested properties", or "Collapse all nested properties" when they are all expanded.
Context menus and editor shortcuts
The built-in items of the context menus bind the commands of the registry by id, like the main menu: each time a menu with a location (CommandSlot.Location) opens, its items written Command="{cmd:Command <id>}" get the command in the menu's context (the location, the selection the menu opened on, the control it opened on as Source, and the editor it opened in), their title unless they have a header of their own, the user's shortcut and, for a toggle, its check; then the commands placed at the location follow. So the shortcut a menu item shows is the one that runs it, and "Add asset..." shows the user's shortcut rather than Ctrl+I. The menus keep their layout in XAML (headings, separators, submenus made from data such as "Include in build as root asset in" and "Update package"); a plugin's view can bind its own menu items the same way.
The Edit commands in a context menu (Stride.Edit.Cut, Copy, Paste, Delete, Rename) act on the control the menu opened on, through the Edit bindings of that control or its ancestors, rather than on the control that last had the focus; so the asset view's Cut cuts the selected assets and a property's Copy copies its value.
| Context menu (location) | Its items |
|---|---|
Asset view (AssetView/Context) |
Stride.Asset.EditSelected, Stride.Asset.ToggleRoot, the Edit commands, Stride.Asset.CopyRecursively, Stride.Asset.CopyUrl, Stride.Asset.NewFolder, Stride.Asset.Add, Stride.Asset.UpdateSelectedFromSource, Stride.Asset.UpdateAllFromSource, Stride.Asset.OpenWithTextEditor, Stride.Asset.OpenFile, Stride.Asset.OpenSourceFile, Stride.Asset.ShowInExplorer, Stride.Asset.ShowSourceInExplorer |
Solution explorer (SolutionExplorer/Context) |
Stride.Asset.NewFolder, Stride.Project.AddDependency, Stride.Project.SetCurrent, Stride.Project.PackageProperties, Stride.Project.NewProject, Stride.Project.AddExistingProject, Stride.Project.OpenInIDE, the Edit commands, Stride.Asset.Add, Stride.Asset.ShowInExplorer |
Property of the property grid (PropertyGrid/Context) |
Stride.PropertyGrid.ResetToBase, Stride.Edit.Copy, Stride.Edit.Paste, Stride.PropertyGrid.Replace (Ctrl+Shift+V), then Stride.PropertyGrid.ToggleNestedProperties in its slot |
Entity tree of a scene or prefab (EntityTree/Context) |
on an item: Stride.Scene.NewFolder, Stride.Scene.NewEntity, Stride.Scene.SetActiveScene (a child scene only), on the empty area: Stride.Scene.NewFolderInRoot, Stride.Scene.NewEntityInRoot; then Stride.Scene.OpenPrefab, Stride.Scene.SelectPrefab, Stride.Scene.BreakLinkToPrefab, Stride.Scene.CreatePrefabFromSelection, Stride.Scene.Duplicate and the Edit commands (on the empty area, Paste is Stride.Scene.PasteInRoot) |
Scene view (SceneView/Context) |
Stride.Scene.NewEntityAtCursor, the prefab commands, Stride.Scene.Duplicate, Stride.Edit.Cut, Stride.Edit.Copy, Stride.Edit.Delete, Stride.Edit.Rename (on the selected entities, through the Edit bindings of the view) |
The commands of the asset view act on the selection the menu opened on, and on the asset view's selection from a shortcut or the palette; those of the solution explorer on its selected items. The commands that only make sense where their menu places them (on the property, on the tree's root or selection, at the cursor) are not in the palette.
The asset editors' own shortcuts are commands scoped to their editor (GestureScope): they are on the Keyboard shortcuts page, run only while the focus is in that editor (before the main window's shortcuts), and act on that editor (CommandContext.Editor).
| Editor | Commands |
|---|---|
Scene and prefab (Stride.Assets.Editor.Commands.SceneEditorCommands, category Scene) |
Stride.Scene.FocusOnSelection (F), Stride.Scene.Duplicate (Ctrl+D), and the commands of their context menus above, with no default shortcut |
Sprite sheet (SpriteSheetEditorCommands, category Sprite sheet) |
Stride.SpriteSheet.PreviousSprite (Ctrl+J), Stride.SpriteSheet.NextSprite (Ctrl+K), Stride.SpriteSheet.AddImage (Ctrl+U), Stride.SpriteSheet.Duplicate (Ctrl+D), Stride.SpriteSheet.UseWholeImage (Ctrl+W), Stride.SpriteSheet.ToggleMagicWand (M), Stride.SpriteSheet.FocusOnRegion (F) |
UI page and UI library (Stride.UI.Editor.Avalonia.UIEditorCommands, category UI) |
Stride.UI.Duplicate (Ctrl+D) |
The scene view's tool and camera keys, the arrow keys of the UI editor's design area and the curve editor's keys are not commands: the editor's game or the view reads them.
Scene and prefab views
The scene and prefab editors declare their contribution points in Stride.Assets.Editor, reached through extension methods of the context (ScenePluginContextExtensions). Both Game Studios have them.
- Tools (
context.SceneViewTools()): aSceneViewToolDescriptornames a tool type and its place in the toolbar (Order; the editor's tools are 0 to 30, a plugin's default is 1000).SceneViewToolDescriptor.For<MyTool>()describes one, and[EditorViewTool(Order = ...)]on the class registers it the same way. Each open view creates its own instance, so the type must be a class with a public parameterless constructor that implementsIEditorViewTool: a type that is not is logged with the plugin's name and left out, and the rest of the plugin joins. The open views follow the registry: a plugin's tools appear in every open view when it joins and leave when it leaves (the view goes back to the select tool if one of them was active, and the tool is disposed). The WPF Game Studio runs a plugin's tools by their shortcut, without a toolbar button. - Running a tool: the editor calls a plugin's tool through the contribution guard. A tool that throws is turned off in every view for the session, the error is logged with the plugin's name and recorded in its state, and the view goes back to the select tool.
Update(CancellationToken)(its default callsUpdate()) runs once per frame on the game thread; the view waits for it for 30 seconds at most, then cancels the token and turns the tool off. - Context menu of the view (cross-platform Game Studio): a right click without a camera drag opens a menu at the cursor with the entries of the active tool (
IEditorViewTool.GetContextMenu(EditorViewClick), none by default; they run on the game thread), then the editor's own entries (create an entity at the cursor, and the actions on the selection, as in the WPF scene view), then the commands placed atSceneLocations.SceneViewContext. The commands get the click (EditorViewClick: the cursor position, the ray through it, the buttons) and, when the cursor is over an entity, itsEntityViewModelas their selection. A tool's menu withReplacesOthershides the editor's entries and the commands; an empty one keeps the menu closed, for a tool that uses the right button itself. The WPF Game Studio keeps its own menu in the scene view (the editor's entries only). - Widgets (
context.SceneViewWidgets(), cross-platform Game Studio): aSceneViewWidgetDescriptordocks a small panel on an edge of the view, over the game (Edge: top, bottom, left or right, thenOrder). It has a uniqueId, aTitlefor the toggle list,VisibleByDefault, andCreateViewModel, which gets aSceneViewWidgetContext(the editor, its session, the tool service) and returns anIDestroyableview model. The view is the one the plugin registers for that view model type incontext.ViewTypes. Each open scene or prefab editor creates its own widgets, the first time they show, through the contribution guard: a widget that throws is turned off for the session, in every editor, and the error is recorded in its plugin's state. The "Widgets" button next to the gizmo options lists them with a check box each; the choice is saved per scene in the package user settings (Package/SceneViewWidgets). The widgets follow the registry like the tools. The WPF Game Studio accepts the registrations and shows nothing.
Migrating from the older plugin API
The API that plugins used before the plugin context is obsolete. It still works, and the editor removes what it registers when the plugin leaves, but a plugin that uses it gets a build warning naming the replacement. It will be removed in a later major version. Each group has its own warning id, so a plugin can silence one group while it moves (<NoWarn>$(NoWarn);STRPLUGIN001</NoWarn> or #pragma warning disable STRPLUGIN001).
| Id | Obsolete | Replacement |
|---|---|---|
STRPLUGIN001 |
The Register* methods of AssetsPlugin and AssetsEditorPlugin (RegisterAssetViewModelTypes, RegisterPrimitiveTypes, RegisterAssetEditorViewModelTypes, RegisterAssetEditorViewTypes, RegisterAssetPreviewViewModelTypes, RegisterAssetPreviewViewTypes, RegisterEnumImages, RegisterTemplateProviders, RegisterCopyProcessors, RegisterPasteProcessors, RegisterPostPasteProcessors) |
Initialize(IEditorPluginContext context), with the registry of the same name: context.AssetViewModelTypes, context.PrimitiveTypes, ... context.PostPasteProcessors |
STRPLUGIN002 |
InitializePlugin(ILogger), StrideAssetsPlugin.Initialize(ILogger) and the helpers called from it: RegisterEnumImage, RegisterTemplateProvider, the instance RegisterResourceDictionary(dictionary) of StrideAssetsWpfPlugin and StrideAssetsAvaloniaPlugin |
Initialize(IEditorPluginContext context): context.Logger, context.EnumImages, context.TemplateProviders, and the static RegisterResourceDictionary(context, dictionary) |
STRPLUGIN003 |
InitializeSession(ISessionViewModel) |
InitializeSession(ISessionPluginContext context): context.Session, context.Services, context.NodePresenterCommands, context.NodePresenterUpdaters, context.OnClose(...) |
STRPLUGIN004 |
The static AssetsEditorPlugin.TypeImages and TypeImagesDictionary |
context.TypeImages, or [assembly: TypeImage(...)]; the editor reads them through IAssetsPluginService.GetImageForType |
STRPLUGIN005 |
The AssetsEditorPlugin.ProfileSettings list |
context.ProfileSettings |
STRPLUGIN006 |
context.EditorViewToolTypes |
context.SceneViewTools() with a SceneViewToolDescriptor (Stride.Assets.Editor), or [EditorViewTool] on the tool class |
A plugin that overrides an obsolete method gets the compiler's own warning, CS0672 ("overrides obsolete member"), instead of the group's id; the base method's message names the replacement.
AssetsPlugin.SessionLoaded and SessionDisposed are gone (they were never called): a plugin does its session work in InitializeSession(ISessionPluginContext context) and its clean-up with context.OnClose(...), which runs when the plugin leaves or the session closes, in both Game Studios.
Before and after, for a plugin with an enum image, a template provider and a property grid command:
// Before
public sealed class MyEditorPlugin : StrideAssetsPlugin
{
protected override void Initialize(ILogger logger)
{
RegisterEnumImage(MyMode.Fast, LoadImage("Fast.png"));
RegisterTemplateProvider(new MyTemplateProvider());
}
public override void InitializeSession(ISessionViewModel session)
{
// added the command to the property grid's service directly, and nothing removed it
}
}
// After
public sealed class MyEditorPlugin : StrideAssetsPlugin
{
public override void Initialize(IEditorPluginContext context)
{
base.Initialize(context);
context.EnumImages.Register(MyMode.Fast, LoadImage("Fast.png"));
context.TemplateProviders.Register(new MyTemplateProvider());
}
public override void InitializeSession(ISessionPluginContext context)
{
base.InitializeSession(context);
context.NodePresenterCommands.Register(new MyNodeCommand());
context.OnClose(() => { /* what the old SessionDisposed did */ });
}
}
Editor versions and experimental API
Which Game Studio a plugin needs. Before a plugin assembly loads, Game Studio reads which versions of its own assemblies the plugin was built against (Stride.Core.Presentation, Stride.Core.Presentation.Quantum, Stride.Core.Assets.Presentation, Stride.Core.Assets.Editor, Stride.Assets.Presentation, Stride.Editor, Stride.Assets.Editor, and the .Avalonia and .Wpf assemblies of each toolkit), without loading it. Only the major and minor versions count: a patch release keeps the assembly version (4.5.0.0 for every 4.5.x), so a plugin built against 4.5.0 works with 4.5.3 and the other way round.
- A plugin built against a newer major or minor version than the running Game Studio is not loaded. The session's log says what it needs ("The plugin [MyPlugin.Editor] of the package [MyPlugin] needs Game Studio 4.6: it was built against Stride.Assets.Editor 4.6.0.0, and this Game Studio is 4.5. It is not loaded."), and its state is incompatible (
PluginState.Incompatible, with anIncompatiblePluginExceptionamong its errors;PluginStatus.Pluginis null, since nothing of it was loaded, andNameis its assembly's name). The WPF Game Studio logs it and goes on without it. The plugin's assets still load, since itsAssetspackage references no editor assembly and is not checked; they open without the plugin's editors, previews and gizmos. - A plugin built against the same version, or an older one, loads as before. If it uses something that is gone from the newer editor, the contribution that uses it fails when it runs, and the contribution guard turns it off alone (see Panels, views and plugin states).
- An assembly that references none of these (the
RuntimeandAssetspackages of a plugin) is not checked.
A game is normally edited with the Game Studio of its own Stride version, so its plugins meet the editor they were built for: the check matters for a plugin package built against another Stride version than the game.
Experimental API. The parts of the plugin API added for the cross-platform Game Studio can still change between minor versions. They are marked [Experimental], with one id per area, so a plugin that uses them says so: until it opts in, the compiler reports an error at each use, naming the id.
| Id | Area | API |
|---|---|---|
STREXP001 |
Panels, views and registries of other layers | context.Panels, context.ViewTypes, context.GetRegistry<T>(), IAssetsPluginService.GetViewType, ContributionRegistry<T>, and the members of EditorPluginHost behind them (ViewTypes, GetViewType, DeclareRegistry, GetDeclaredRegistry) |
STREXP002 |
Plugin states, the contribution guard and the version check | PluginState, PluginStatus, PluginError, PluginStatusChangedEventArgs, IPluginContributionGuard, PluginContributions, EditorApiCheck, IncompatiblePluginException, IAssemblyLoadCheck, and the members of EditorPluginHost behind them (PluginStatuses, GetPluginStatus, PluginStatusChanged, AssemblyLoadCheck, TryRun, TryRunAsync, IsTurnedOff); switching plugins off and safe mode: ICompanionPackageFilter and CompanionPackageFilter (PackageLoadParameters, PackageSession), PluginOffReason, BuiltInPlugins, EditorCompanionFilter, DisabledEditorCompanions, DisabledEditorCompanionStore, PluginInfo, PluginSource, PluginCatalog, PluginSwitchService, PluginLoadingMarker, and the members behind them (SafeMode, LoadingMarker, DisabledCompanions, GetCompanionPackageFilter, GetContributionCounts); editor extensions: ICompanionPackageSource and CompanionPackageSource (PackageLoadParameters, PackageSession), PackageSession.SourceCompanionPackages and LoadedSourceCompanionPackages, EditorExtension, EditorExtensionList, EditorExtensionStore, EditorExtensionService, ExtensionPackageInfo, EditorExtensionInstallResult, the RestorePackage overloads of PackageStore and NugetStore that take more sources, and the members behind them (Extensions, GetCompanionPackageSource) |
STREXP003 |
Commands, menus and toolbars | context.Commands, context.ToolbarWidgets, the types of Stride.Core.Assets.Editor.Commands (CommandDescriptor, CommandPlacement, CommandLocations, CommandCategories, CommandContext, CommandGesture, CommandGestureBindings, SessionCommands, ToolbarWidgetDescriptor, ...), SceneLocations, SceneEditorCommands, SpriteSheetEditorCommands, UIEditorCommands, and the Avalonia CommandSlot, CommandReference, DescriptorCommand and PropertyGridCommands |
STREXP004 |
Tools of the scene and prefab views | context.SceneViewTools(), SceneViewToolDescriptor, IEditorViewTool.Update(CancellationToken) and GetContextMenu, EditorViewContextMenu, EditorViewMenuEntry, and the view's context menu |
STREXP005 |
Widgets of the scene and prefab views | context.SceneViewWidgets(), SceneViewWidgetDescriptor, SceneViewWidgetContext, SceneViewEdge, and the view models of the widgets |
STREXP006 |
Services | IPluginServiceRegistry and context.Services.Register<TService>(factory, lifetime) (PluginServiceRegistryExtensions), CreateInstance<T> of PanelContext, ToolbarWidgetContext and CommandContext; the service scopes behind them: IViewModelServiceProvider.Register<TService>(factory, lifetime), ServiceProviderExtensions.CreateInstance, AssetEditorViewModel.Create and the asset editors' constructors that take an IViewModelServiceProvider |
STREXP007 |
Services of the scene editors | IEntityPickerService and IPickedEntity (the Pick buttons of the entity and component properties), IGraphicsFrameCaptureService (a frame debugger's capture of the light probe and cubemap steps) |
STREXP008 |
Deploying games | IGameDeployer, BuildAndRunViewModel.RegisterDeployer, IGameProjectBuild.TargetOutputs |
STREXP009 |
Several views of a scene | IEditorGameMultiViewport, EditorGameViewInfo, IEditorGameMultiViewViewModelService, EditorGameMultiViewService, EditorViewCamera, EditorGameViewCamera, EditorGameViewCameraInfo, EditorGameViewCameraState, IEditorGameViewDependent, EditorViewLayout, EditorViewLayoutViewModel, EditorViewPaneViewModel and the Avalonia EditorViewLayoutPanel |
STREXP010 |
Node graph controls | The Avalonia NodeGraphControl, NodeGraphNode, NodeGraphConnector, NodeGraphLinkRequest, NodeGraphLinkStyle, NodeGraphSlotDirection and INodeGraphLinkResolver, and the arguments of its events (NodeGraphNodeMove, NodeGraphNodesMovedEventArgs, NodeGraphNodeEventArgs) |
STREXP011 |
Test kit of editor plugins | The Stride.Core.Assets.Editor.Testing and Stride.Assets.Editor.Testing packages (see Testing a plugin's view models) |
To use an area, opt in to its id in the Editor project, for the whole project:
<PropertyGroup>
<NoWarn>$(NoWarn);STREXP003</NoWarn>
</PropertyGroup>
or around the code that uses it (#pragma warning disable STREXP003). Opting in says that the plugin may need changes for a later minor version of Game Studio: an experimental member can change or go in any minor release. The rest of the plugin API (the plugin context's other registries, the attributes, the asset view models and editors) follows the usual rules: it changes only in a major version, after a release where it is obsolete (see Migrating from the older plugin API). The STREXP ids are not the STRPLUGIN ids of the obsolete API: an experimental member is new and can still move, an obsolete one is old and will go.
Reloading in Game Studio
Game Studio reloads a plugin's assemblies while the session stays open. It asks first, or the user runs Reload game assemblies. The reload is one undo step.
- A plugin project of the solution: an edit of its code (
.cs), its views (.axaml,.xaml), its resources (.resx) or its.csprojbuilds it again, and it reloads. - A dependency built locally (a dev-redirect to a source tree, as
build/redirect-packages.cssets up): Game Studio watches the assemblies the checkout built. When they are rebuilt, they reload. - A
PackageReferenceversion change in a project of the solution: the project restores, and the dependency loads its new version. In a source checkout (dev-redirect packages), a library is compared with the checkout's build, which the game builds against, not with the copy the redirect package keeps.
With any of these, the loaded assemblies that reference a reloaded one reload too, whatever their package, dependencies first: a reference stays bound to the copy it loaded first. Each assembly gets a load context of its own. A reference resolves to the session's current copy first, then to Game Studio's own copy, then to the package's files. The whole set builds before anything reloads: if one build fails, nothing reloads, and the changes stay pending.
Some changes need a new session (Reload session). The Output panel says which one and why, and nothing reloads:
- A version change where the new version adds or drops an assembly, the package ships assets, or the package has companions (their versions follow it).
- An assembly Game Studio's own code is bound to: one it ships with (the engine's packages, at the version it was built with), or one that its code looked up by name. A new copy next to it would mix the types of both.
A package from the NuGet cache never changes for its version, so it is only reloaded when another version replaces it.
The Avalonia Game Studio reloads the game's code the same way, in its own process. Where a change can't reload in place, it opens the session again in a new process (after asking to save) instead: the cases above, an assembly with Avalonia views (a plugin's views, styles and templates stay registered with Avalonia), and an assembly the session could not load. The Output panel says why.
The open editors follow a reload, its undo and its redo: the objects of the reloaded types are replaced in their assets, and each editor game (and the asset preview) replaces the components, drops the processors and [GameSystem(Editor = true)] systems of the old types and creates the new ones.
Testing a plugin's view models
Two packages open a session in a test, the way Game Studio opens one, without its windows: Stride.Core.Assets.Editor.Testing (the session and its stand-ins, for any editor layer) and Stride.Assets.Editor.Testing (the same with Stride's assets and editors, which most plugins want). They don't depend on a test framework, and Stride's own editor tests use them. They are experimental (STREXP011).
await using var session = await StrideEditorTestSession.OpenAsync(new StrideEditorTestSessionOptions
{
Plugins = [new MyEditorPlugin()],
StandInEditors = [typeof(MyAssetEditorViewModel)],
}, ("Stories/Intro", new MyAsset()));
var asset = session.Asset<MyAssetViewModel>("Stories/Intro");
session.Session.EditorCollection.OpenAssetEditor(asset);
- The session writes a package with the given assets in a temporary folder and opens it with the plugins of the test and Stride's default assets plugin. Disposing it closes the session as Game Studio does: the plugins leave it and the actions they registered with
context.OnCloserun, then it waits for its background work and deletes the folder. A session service that stops its background work inOnCloseis stopped there, before the wait. - An
ExclusiveDispatcherServiceis the UI thread.OpenAsyncreturns aDispatcherTask: a test that awaits it goes on in the dispatcher, where it changes the session and disposes it, as the editor does on its UI thread. A test of views gives the toolkit's UI thread instead (see below). - The session opens the editor of an asset only when a view is registered for it:
StandInEditorsgives the editors of the test a stand-in view. A test of the views themselves registers the plugin's toolkit companion instead. - The dialog and clipboard services throw
NotSupportedExceptionunless the test gives its own inServices.TestEditorDialogServiceis a dialog service the test scripts: the message boxes take the answers of itsAnswersqueue, thenAnswer(a message box with buttons of its own takes the button of the answer, orPickButton); the dialogs and pickers take what itsPick...functions return, a cancel by default. It records the questions (Messages,AssetPickers, ...) and none of them throws. - The progress windows show nothing: the session has a
TestProgressWindowServiceunless the test gives its own (aTestEditorDialogServiceis one too), so a test can run the session's own save,SaveSessionAsync, the one that tells the assets they were saved. InitializeSessioninitializes the plugins for the session, as Game Studio does once its views are ready, for a test of the session services and commands they register.- The sessions share one dispatcher and Game Studio's process-wide registries, so tests that open them can't run in parallel. Turn parallel runs off in the test project: for xUnit,
[assembly: CollectionBehavior(DisableTestParallelization = true)]; other frameworks have the same setting. A session that opens while another test has one open fails at once with a message that says so (without the check, the run would hang). One test can open several sessions, one after the other or together. - The package loads without a NuGet restore or an MSBuild evaluation of its project. The assemblies of the plugin's assets must be registered first (
AssemblyRegistry.Register(typeof(MyAsset).Assembly, AssemblyCommonCategories.Assets), in the module initializer or a static constructor of the tests). - A test project is a program (xunit.v3 makes it an
Exe), but the build compiles its assets as a game's only when it has a Stride package of its own: an.sdpkgbeside the project, aStrideCurrentPackagePaththat names one, orStrideIsExecutableset totrue. A test project with none (the test SDK setsIsTestProject) builds without the asset compiler, so it needs noStrideCompilerSkipBuild. - The session evaluates projects with the MSBuild of the .NET SDK, and the Roslyn packages that the editor packages bring would put an older
Microsoft.Build.Frameworkin the test output. The package keeps the MSBuild assemblies out of the output of the projects that reference it (StrideEditorTestingKeepMSBuildRuntimeset totrueturns that off).
A headless test of a plugin's views (Avalonia.Headless) runs on Avalonia's UI thread, and the views must get the session's changes there. Dispatcher makes that thread the session's UI thread: the test opens the session from it, never leaves it, and its awaits let the session's work run. The dispatcher service comes from Stride.Core.Presentation.Avalonia, which the views' project references already.
[AvaloniaFact]
public async Task TheViewShowsTheNewTitle()
{
await using var session = await StrideEditorTestSession.OpenAsync(new StrideEditorTestSessionOptions
{
Plugins = [new MyEditorPlugin()],
// Stride.Core.Presentation.Avalonia.Services.DispatcherService
Dispatcher = DispatcherService.Create(),
}, ("Stories/Intro", new MyAsset()));
var story = session.Asset<MyAssetViewModel>("Stories/Intro");
var window = new Window { Content = new MyAssetView { DataContext = story } };
window.Show();
story.Title = "Prologue";
Dispatcher.UIThread.RunJobs();
// ... check the view, then close the window before the session is disposed
window.Close();
}
Known limitations
An editor still closes when it can't follow a reload, its undo or its redo: its asset is restored as a whole (its own type is reloaded), or the editor, its controller, its game or one of its editor game services comes from a reloaded assembly, or an assembly that goes or comes declares gizmos (the existing ones aren't recreated) or render features (
IRenderFeatureProvider, the editor's compositor isn't rebuilt). Its changes stay in the session; on the reload itself, the Output panel lists it to open again.Thumbnails keep the render features of a reloaded plugin as they were created: reload the session to get the new ones.
The old assemblies stay in memory until Game Studio closes.
Game Studio's lists are not limited to the project being edited: they show what every package of the session brings. This covers the Add asset templates, the Add component and Create entity menus, the gizmo list, the type pickers of the property grid and the asset picker. With two games (or a game and a library) in one session, the plugins and scripts of one show up while editing the other.
PackageTypeScope.For(package).Contains(type)tells whether a type is available to a project, as the render features of a compositor already use it.