02 – Creating a Plugin Project

Introduction

This tutorial provides instructions for creating a simple Glue plugin. This is the first step in creating any new plugin.

Obtaining Source

The easiest way to create Glue plugins is to use download and develop your plugin in a solution which includes Glue source. Instructions for downloading Glue source can be found on the following page:

FlatRedBall Source

Before continuing you will want to make sure you can build and run Glue from source (Glue.sln).

Creating a new SLN

After successfully building and running Glue from source, the next step is to create a new .sln (solution file) for your project. Keep in mind that you do not need to create a new .sln for every plugin you are developing – it may be convenient to have multiple plugins in one .sln file.

To create a new .sln file:

  1. Open the folder where Glue.sln is located – on my machine this is located at C:\Users\Victor\Documents\FlatRedBall\FRBDK\Glue


    Notice that this folder already has multiple .sln files for different plugins such as Gum and Tiled

  2. Create a copy of Glue.sln in the same folder

  3. Rename the newly-created file to indicate the plugin you are developing. For example, I will name mine Glue with TutorialPlugin.sln

Creating a Plugin Project

Now that we have a .sln file to hold our plugin, we can create a new .csproj (project) file. To add a new .csproj to your newly-created .sln file:

  1. Open the newly-created .sln file (mine is called Glue with TutorialPlugin.sln)
  2. Collapse the projects in the solution explorer – this will make it easier to add new projects

  3. You can choose how you prefer to organize your plugin. Common approaches include adding a new folder for your plugin at the root of the solution, or adding your plugin to the existing Plugins folder. For this tutorial I will create a new folder at the root of the solution called Tutorial. Right-click on the solution and select Add -> New Solution Folder

  4. Name the folder Tutorial

Larger plugin projects may contain multiple projects, so creating  a folder for your plugin is a good way to keep the projects organized. Next we’ll create a new .csproj file for the plugin:

  1. Right-click on the Tutorial folder and select Add -> New Project

  2. Select the Installed -> Visual C# -> Windows Classic Desktop category
  3. Select Classic Library (.NET Framework)
  4. Change the .NET Framework to .NET Framework 4.6

  5. Enter a name for your plugin project and click OK. I’ll name mine TutorialPlugin

After clicking OK, the project will appear in the Solution Explorer.

Adding Project References

Tutorial projects must reference FlatRedBall and Glue libraries to be able to make changes to Glue at runtime. Most plugins also require referencing a few other libraries for displaying UI. Some references will be added from projects in the solution, while others are standard libraries.

To add project references:

  1. Expand the newly-created TutorialPlugin project in the Solution Explorer
  2. Right-click on the References item and select Add Reference…

  3. Click on the Projects category

  4. Check the following projects:
    1. EditorObjectsXna4
    2. FlatRedBall.Plugin
    3. FlatRedBall.PropertyGrid
    4. FlatRedballXna4
    5. Glue
    6. GlueSaveClasses

Glue plugins typically often require a set of libraries for WPF development, as Glue plugins can host WPF controls. To add these libraries:

  1. Right-click on the References item and select Add Reference…
  2. Select the Assemblies -> Framework category

  3. Check the following libraries:
    1. PresentationCore
    2. PresentationFramework
    3. System.ComponentModel.Composition
    4. System.Windows.Forms (this is needed even though we’re using WPF)
    5. System.Xaml
    6. WindowsBase
  4. Click the OK button

At this point you will see all of the referenced projects under the References.

Now that we have our references set up, we will create our plugin class in the next tutorial.