Proper docs for creating a plugin

Hi, I searched for a proper docs, how to create a plugin from zero to a “here comes a big one”, but found only some questions on stackoverflow and wiki on ue4. There’s some main stuff how to begin with, but no information how to continue and at least some info on code style and style of creating new classes etc.

So I’ll tell a few words, what are the main points of plugin from my noobish point of view and then ask you, how to continue that or edit my mistakes, if I understood wrongly.

Basically I looked in other plugin, that’s already implemented and actively used in the project called VaRestPlugin and tried to do something similar.

First important part is that you need add


file, to modules array the name of your plugin f.e. like here:


     "Name": "My Plugin",
     "Type": "Runtime",
     "LoadingPhase": "PreDefault"

Basically that’s it. Buut, I totally don’t know, what’s “Type” and what’s “LoadingPhase”. Maybe its just a stage at which plugin will be loaded into the project. And I hope somebody can explain me it here.

Second, we move on and there’s C# file, called *.Build.cs and there’re just some includes from UE4. What I did, I just included basic stuff like “Engine”, “Core”. I guess that’s the basic stuff, that every plugin should have. I also use “CoreUObject” if you want to have functions, which you can add in BPs.
And I almost forgot about there’re functions called public dependencies and private dependencies. Well the name tells, what this stuff do, by itself. Public - outworld plugins, source code, third party services etc. Private - now there some stuff I think I don’t understand about this, but I’m guessing, what this stuff does is making all plugin in one piece or in smart words collects all the source files to one place, which means just makes


to whatever you write.

Ok, moving on.

There’s some conventions where to place your files. Basically in good plugin you have 3 of those: Public, Private and Classes. First 2 are explained on wiki, Classes is just a folder for header source code, that use BP macroses.

Basically what you should have is a Public/IMyPlugin.h. This file usually has default source code, f.e. here:

class ISocket : public IModuleInterface
	static inline ISocket& Get()
		return FModuleManager::LoadModuleChecked<ISocket>("SocketPlugin");

	static inline bool IsAvailable()
		return FModuleManager::Get().IsModuleLoaded("SocketPlugin");

What you need to turn attention to, the arguments to these functions should be the name of your plugin(in my case its SocketPlugin) and template should be the same as class.

There’re 2 more required files of source codes:

  1. MyPluginPrivatePCH.h - source file, where you put all your headers. In most cases they’re just general engine files and public files. Example:

#pragma once

#include "CoreUObject.h"
#include "Engine.h"

#include "ModuleManager.h"
#include "ISocket.h"

  1. MyPlugin.cpp. It should be named as your plugin with cpp added. Basically what this class does it, do some stuff when you startup plugin and when you shutdown it.

Why you need this? To load some other classes you’ve made and create a ue4 module. Example:

#include "SocketPrivatePCH.h"

class SocketImpl : public ISocket
	virtual void StartupModule() override
	virtual void ShutdownModule() override

IMPLEMENT_MODULE(SocketImpl, Socket)

Hm, what to turn attention to. First, you include, that PCH header file, then create a class which extends class that was from Public/IMyPlugin.h. Second to override functions StartupModule() and ShutdownModule(). Third there’s a UE4 macros IMPLEMENT_MODULE, first argument should name of class in the MyPlugin.cpp, second the name of the plugin.

Basically its a good to go plugin, then you just need to generate binaries for plugin. This can be done with right mouse button on *.uproject → generate VS project files.

Ok this stuff is for those, who starts doing a plugin and is stuck at basic level.

And my questions.

You see in code above, there’s a code line


, which must include an external class to the module, but it doesn’t. So, how can I include this static class into startup module?

P.S. As the conversation progresses I’ll add new stuff that ppl will tell me and I’ll test it myself, that it works. Again for other newcomers like myself.

P.S.S. Because in my point of view, wiki and sources, doesn’t explain fully the given topic.

Thanks to everyone, who shares ideas and knowledge.

I have limited knowledge of C; but the above are just basic C programming (headers, constructors etc) pick yourself up a good C programming book and have a look at the api’s if they’re available.

Hi there…

I’ve done a few plugins and the documentation is a bit…well…could be better. What I would suggest (to get more ideas) is watch the first 20 minutes or so of this video: – Now, I did NOT do the dummy object and I tested everything fine. I wrote myself a cheat sheet that’s super basic and its so bad that I will not share here. But, I am thinking about doing a wiki entry.


You are mistakenly talking about ‘name of plugin’ when in fact you are referring to ‘name of the module’.
That one you declare into Modules array within *.uplugin file.

People often name it after the plugin’s name, but isn’t needed to; you can have 1 plugin with a dozen different modules.
Each module has one Build.cs file, again, not the plugin. Each Build.cs file is meant to tell Unreal Build Tool that this new Module is supposed to be considered for building when packaging the game.

A “Runtime” Module is a module that will be loaded in the game; a “Editor” module will be used only when you run Unreal’s Editor and will be discarded when packaging the game.
“PreDefault” is a Module that will be loaded before default game modules.
“Default” loads alongside common game modules, these can create classes based on the ones created by ‘PreDefault’ modules.

When you need to use classes from a Module, you need to include its Build.cs class as a dependency.
To let the other external modules to use functions or objects created within your plugin module, you export the function or class using the Macro UE4 creates for you which is ‘moduleName’+"_API", example:

class MYMATHMODULE_API UMyMathClass : UObject {…}

void MYFUNCLIB_API CalculateStuff();

If you declare the function or class, without its export macro (and its not a static function), when you try to instantiate the object or use the function from another module you’ll get linker errors “@ missing blah blah”.

If you want to use external libraries, your plugin module must provide both include header files and a binary *.lib files within a “ThirdParty” folder for static linking.
If you want to use a DLL without explicitly loading it into memory, you must provide a secondary module for the Dll and in its Build.cs rules add " Type = External; " then add it to the public library dependencies and add it as a new runtime dependencies which tells UBT to package the game together with the extra DLL file (it will automatically copy the DLL file to the output path when packaging the game).

How to update a plugin from 4.12 to 4.15/4.16 please.

hey guys,

I have created a whole tutorial on how to include third-party libraries into unreal with a custom plugin. Have a look here: How to include Third Party library (like boost / PCL) in a custom plugin? [SOLVED] - UE4 AnswerHub