Anatomy of plugin

1 Architecture 1.1 Plugin Descriptor File A .uplugin file, which is a plain-text file that stores Plugin Descriptors in a JSON object. It will exist at the root directory of the Plugin. TODO - expa...

Updated about 4 years ago Edit Page Revisions

1 Architecture

1.1 Plugin Descriptor File

A .uplugin file, which is a plain-text file that stores Plugin Descriptors in a JSON object. It will exist at the root directory of the Plugin.

TODO - expand

1.2 Modules

Plugins may contain one or more Modules, which are implemented by creating a class that inherits from

IModuleInterface

and overriding the '''

StartupModule

''' and '''

ShutdownModule

''' methods, etc. Each Module will exist in its own subfolder under the Plugin's "Source" folder. A Module may also act as a controller (in an MVC architecture) in which methods are implemented to perform actions. When a new Plugin is created, a Module will automatically be generated in the Plugin's "Source" folder and its generated folder and module will be given the same name as the Plugin, e.g.

The Module's path:

/MyPluginTitle/Source/MyPluginTitle

The Module's header file:

/MyPluginTitle/Source/MyPluginTitle/MyPluginTitle.h

The Module's type name:

FMyPluginTitleModule

Listing 1 below shows the module header generated for a plugin from the Editor Toolbar Button template with the name MyEditorToolbarButton. Note that it does not contain a reflection header, i.e. *.generated.h

Listing 1: Generated Module from Editor Toolbar Button Template

// PackageButton.h
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"

class FToolBarBuilder;
class FMenuBuilder;

class FPackageButtonModule : public IModuleInterface
{
public:

    /** IModuleInterface implementation */
    virtual void StartupModule() override;
    virtual void ShutdownModule() override;
    
    /** This function will be bound to Command. */
    void PluginButtonClicked();
    
private:

    void AddToolbarExtension(FToolBarBuilder& Builder);
    void AddMenuExtension(FMenuBuilder& Builder);

private:
    TSharedPtr PluginCommands;
};

The generated Module above also contains a variable for storing Commands, "PluginCommands". In the following sections, it will be discussed how the UI_COMMAND macro is used to create commands with CommandIds that may be mapped to methods defined in the module using the method:

PluginCommands->MapAction(...)

The CommandIDs may also be assigned to UI Elements, such as a toolbar button or menu button, which will perform the action bound to the ID -- as opposed to binding the method to the UI element.

A Module is also used to Initialize its Style if it has one.

1.2.1 Module Descriptors

Name - TODO

Type - TODO

Loading Phase - TODO

1.2.2 Commands

TODO

1.2.2.1 Command Class and Creation

TODO

1.2.2.2 Command Registration

TODO

1.2.2.3 Command Mapping

TODO

1.2.2.4 Editor Keyboard Shortcuts

TODO

1.2.3 Style

TODO

1.2.4 Extenders and UI Extension Points

TODO

2 Plugin Editor Settings

TODO

3 Automation Scripts

TODO

4 Tools

TODO

5 Custom Editor Mode

TODO