x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How exactly do GAME plugins work?

I understand that the plugin system is WIP, but in the context of how it is currently I'd just like to clarify a few things:

How do we use plugin functions in our game code?

So I have a plugin in my MyProject\Plugins folder that is self-contained and compiles correctly. How do I then call a function that is defined in, for example, MyProject\Plugins\MyPlugin\Source\MyPlugin\Classes\RandomFile.h from my project's normal game code?

My first inclination was that this has something to do with modules. I have exposed a module FMyPlugin with alias MyPlugin that I then added to the PublicDependencyModuleNames of my own project's build file. This does not, however, cause any header files from the plugin to be loaded as dependencies for my game.

I suppose what I'm really asking is how to statically link the plugin to the code, just as stated in the documentation:

If you're creating a game plugin (not engine plugin), and you want to allow the game to statically link against one of your plugin modules

Yeah, how is that done?

Are Runtime modules also loaded into the editor plugin browser?

I have the following in my .uplugin file:

 "Modules" :
 [
     {
         "Name" : "MyPlugin",
         "Type" : "Runtime"
     }
 ]

Yet my plugin does not show up in the browser, and the module defined in the plugin is not shown to be loaded in the Modules Developer Tools window. Of course, my plugin is really for the game only so it's not essential to see it in the editor (except to know that it is being loaded), but the documentation states that a Runtime module is always loaded.

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '14 at 02:18 AM in C++ Programming

avatar image

ue4-archive ♦♦ STAFF
49.9k 3662 1988 9113

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey William, It should be loaded, if you are seeing it in the modules, it may be an issue that it’s just not auto loading it, which can happen, if you press the load button it should remember and stay loaded each time you open the editor. If it’s not actually appearing in that list, check the binaries folder of your plugin for the generated DLL file. Let me know if that is not there.

Best Regards,

Ryan

more ▼

answered Mar 11 '14 at 02:18 AM

avatar image

ue4-archive ♦♦ STAFF
49.9k 3662 1988 9113

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:18 AM

Hi, thank you for the response. It's not showing in either the plugin list or the modules list. I have the following DLL: RocketEditor-MyPlugin-Win64-Debug.dll at the path Plugins\MyPlugin\Binaries\Win64.

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:18 AM +

@Mike: Actually, the problem of seeing my plugin in both windows resolved itself last night somehow. I wish I knew why; but at least that part is working like it should now and it appears to always be loaded like a runtime plugin should.

Alright so I had my plugin in PublicDependencyModuleNames instead of PrivateDependencyModuleNames, I suppose private makes more sense in this case since most of my plugin code is in the private folder. Is there any other difference between these two arrays I should be aware of?

And the way I have it currently working is, I add MinimalAPI to my UCLASS() specifier in any class I want to expose as public to my game, and then tag every function I want to be callable from my game with MYMODULE_API. This works, but the problem in my other question (about the missing DLL) still exists. Is there a step missing here? Specifically, I'm interested in the interface wrapper class. It looks like that's how you guys do OnlineSubsystem.h, which wraps not only the online subsystem classes but the module, and then those classes don't need API specifiers...?

Sorry for all the questions, but I'm really liking this plugin system and I just want to understand it better. Thanks!

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:18 AM

Right, the idea with interface classes is that you don't need any API specifiers. Instead, you create an abstract class with all of the functions that you'll need marked as virtual. Often that class will inherit from IModuleInterface, so that it can easily be exposed through the ModuleManager. You inherit that class somewhere in your plugin module's private implementation. The consumer of your plugin can get access to that implementation through the interface when calling LoadModule(). When a module is setup this way, we call it a "dynamically loaded module". There is no link-time dependency, because nothing was exported using MYMODULE_API (also known as __declspec(dllexport)).

You can see dozens of examples of modules setup this way in the various public headers for the editor and engine modules.

Here is the catch. There is not a good way to expose UObjects defined in your plugin to game code to use directly through an abstract interface. If your game needs to be able to instantiate, cast to, and serialize a UObject that you've defined in a plugin, often there is no choice but to use an API-style interface and statically link it to your game module as a PrivateDependencyModule.

--Mike

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:18 AM

Ah I see I get it now, thank you for the detailed response!

Unfortunately yes in this case I have some custom UObjects I'd like to expose, so it seems that the API way is the way to go.

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:18 AM

That's totally fine. We use UObjects in plugins this same way.

--Mike

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question