Download

[Tutorial] Introduction to UE4 Plugins

The plugin system has been tamed, and is at least able to be molded into something fun. If you interested in building a plugin out, now would be a good time to give it a go. Let me know of any feedback you have. As it is a wiki, editing is appreciated.

Hey Bob,

I like the simplicity of your introduction to the topic. I’m going to give this a try ASAP. However, I have a small question regarding extending the editor. Like say I want to add a new button on the top of the editor (near say the QuickSettings button). How would you suggest approaching that? Any pointers are appreciated!

Thanks. :slight_smile:

Extending the editor is not something I have looked into, but since the editor has all of its UI handled with Slate, that is where i would start. There is a tool built into the editor called the Widget Reflector - it allows you to mouse over the different widgets in the editor and shows the hierarchy up to it. The second place I would go is the code. Dive into the Source/Editor folder and look around for any slate elements. There is likely a toolbar or menu element that would allow you to append another widget. I would then go through the plugins and look for some bearing on how others have hooked into the editor, and if there isn’t enough information in the above I would post a formal request for tutorial on the wiki - https://wiki.unrealengine.com/Category_talk:Tutorials.

Thank you for the clues. I’ll start digging. :smiley:

Ok, so after some digging I think extending the editor is not supported yet. My reasoning as follows (and I could be wrong though):

In SLevelEditor.cpp Line 534, there is this function called SpawnLevelEditorTab(), executed multiple times, where in each a section of the editor is built until the whole thing is rendered. Now In my example, I want to add a new button to the toolbar next to QuickSettings (or wherever in the toolbar really). So in the same function, line 569, there is **MakeLevelEditorToolBar() **responsible of constructing it. When you navigate to its definition in LevelEditorToolbar.cpp line 23, you will find the following:


        FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
	**TSharedPtr<FExtender> Extenders = LevelEditorModule.GetToolBarExtensibilityManager()->GetAllExtenders();**

	static const FName LevelEditorToolBarName = "LevelEditorToolBar";
	FToolBarBuilder ToolbarBuilder( InCommandList, FMultiBoxCustomization::AllowCustomization( LevelEditorToolBarName ), **Extenders **);

There is this **ToolBarExtensibilityManager **object (in LevelEditor.h) that seems to be in charge of doing any customization on the toolbar. All extensions are combined into one variable and returned to Extenders (via GetAllExtenders()). Next, this variable is passed to the constructor of the ToolbarBuilder, and the problem is within the constructor itself. It’s empty (MultiBoxBuilder.h line 311). Nothing happens to the passed Extenders variable (or at least I think so), and thus I think it hasn’t been implemented yet.

I will ask this question in the AnswerHub tomorrow, but thought I’d share my findings in case you are interested to double check. :slight_smile:

Hello again,

So I’ve done the StandAlone section of the tutorial, all compiles well. The problem is that I can’t find my plugin in Windows->Plugin screen. Any ideas?

Edit: Found the problem.



{
    "FileVersion" : 3,
 
    "FriendlyName" : "Bob's Plugin",
    "Version" : 1,
    "VersionName": "1.0",
    "EngineVersion" : 1579795,
    "Description" : "Here I describe the capabilities of the plugin.",
    "Category" : "Bobs.Stand Alone",
    "CreatedBy" : "Bob Chatman",
    "CreatedByURL" : "http://gneu.org",
 
    "Modules" :
    
        {
            "Name" : "StandAlone",
            "Type" : "Developer",   **//<------- comma must be removed**
        } 
    ]
}


The descriptor text you have (for StandAlone) in the tutorial has a syntax error.

Thanks! Good find.
I guess i had left that in when playing with the Loading Phase. =\ My Apologies.

Sorry, I’m confused. What’s the difference between a plugin and a bundle? I don’t actually see that discussed in Concepts and Limitations, and actually, the word “plugin” gets used a lot more later. Could you please clarify?

The article went through a number of revisions, so I apologize for that. The truth is, the term Bundle was suggested by some of the Epic developers to describe the three types of modules in a way that is accurate. It seems that in the months since this article was originally created Epic has decided to lean in the direction of Plugin being the term of choice in talking about them. Don’t let this hold you back though! Dive in, make something amazing and come back to tell us about it!

=)