Creating a Plugin Class
Last updated
Last updated
Every FlatRedBall plugin must have one class which implements PluginBase. This tutorial provides instructions for implementing the PluginBase class in a plugin.
To add a main plugin class to your project:
Right-click on your project (mine is TutorialPlugin)
Select Add -> New Item...
Enter the name for your plugin (I will name mine MainTutorialPlugin)
Click the Add button
We will make the following modifications to our class:
So far our plugin doesn't do anything yet, but it does have all of the requirements to be an active plugin which can be detected by Glue.
Now that our plugin is ready to be used in Glue, we can add it to be loaded by Glue. While developing plugins, we can add a post-build process to copy the compiled .dll to a location where Glue will find it. To do this:
Right-click on your plugin project and select Properties
Click the Build -> Event category
Create a script in the Post-build event command line: section to create a directory and copy your .dll. You may need to modify the path to point to the correct location.
Notice that the script above assumes that the plugin is called TutorialPlugin - change the script as necessary if your plugin is named differently.
Build your project, then take a moment to verify that your plugin was successfully copied to the Plugins folder in the Glue bin folder.
Glue will automatically load any files in the plugins folder. Our plugin is set up to be loaded, so we can run Glue to see it. We can run Glue from Visual Studio to see our plugin in the plugin Window:
Run Glue from Visual Studio
Once Glue has finished loading, select the Plugin -> Manage Plugins menu item
Look for Tutorial Plugin in the list of plugins (or whatever FriendlyName your plugin is returning)
Note that the plugin is displaying its version of 1.0. Increasing the version number is a good way to verify that your changes are making their way into Glue if you're unsure. You can optionally specify the version number in your plugin, as shown in the following code: