PLUGIN SDK / Plugin and host / EditorPlugin
EditorPlugin
Base class of a C# editor plugin. The editor creates one instance per build of the plugin's assembly, sets Host and calls OnLoad; register commands, panels, settings pages, services ... there. Saving a source file rebuilds the plugin and replaces the instance (hot reload): every registration is removed, OnUnload runs, the old assembly is unloaded and a new instance loads. Fields therefore reset on reload; keep what must survive in PluginHost.GetSetting / PluginHost.SetSetting.
Kindclass
NamespaceKroys.Plugins
Members3
Source
EditorPlugin.csEXAMPLE
In a plugin
A complete plugin that uses EditorPlugin.
Guides.cs
public sealed class HelloPlugin : EditorPlugin { // One class per plugin assembly. The editor creates it, sets Host and calls OnLoad. public override void OnLoad() { Host.Log($"Hello from {Host.Id}, SDK {Host.SdkVersion}"); Host.AddCommand(new CommandOptions("Greet", "Say Hello"), () => Host.Notify(Severity.Info, "Hello", "Hello from a C# plugin.")); } }
REFERENCE
Members
Properties
#public PluginHost Host { get; }The editor host of this plugin (valid from
OnLoad on).Methods
#public abstract void OnLoad()Registers the plugin's extensions. An exception here refuses the load.
#public virtual void OnUnload()Last call before the build is unloaded (the host already removed the registrations).
Signatures
public PluginHost Host { get; } public abstract void OnLoad() public virtual void OnUnload()
KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.