Hi, I’ve just been into UE for a little over two months with self-taught c++ and not much programming experience. The questions I’m about to ask here might seem trivial for experienced people but I hope you guys can bear with me and give me some insights on this topic.
My goal is simple: a general way to add a module. Now this goal is also somewhat vague since I don’t yet have the enough knowledge on this topic to make a very precise demand.
I’ve googled a lot on this and have come up with a rough system about how this works, which I will explain below with the sources. This rough understanding raises lots of questions, which I hope will get an answer from you.
Now from all the sources I’ve read so far, they both share a common thing on how to add a module: You play with several files and that’s it. So my system so far is in the perspective of what files you play with and how you play with it.
From https://www.sandordaemen.nl/blog/cre…real-engine-4/ and A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums (which are surprisingly similar in content), it seems that there are five files you need to play with in order to add a module:
- **.uproject file **
- .target.cs file for the module to add
- .build.cs file for the module to add
- .h file for the module to add
- .cpp file for the module to add
For the .uproject file, the way you play with it is that you add a module entry in this file for the module you are adding or creating. This entry involves some fields such as Name, Type, Loading Phase. These names are fairly self-explanatory. However, my question is what does adding this module entry do? How does it fit in the big picture of the whole process? By whole process I mean maybe a flow chart explaining roughly how modules are connected and loaded to your project.
For the **.target.cs **file, you need to put a command like ExtraModuleName with your module name as the argument. However, it seems that this step is somewhat deprecated in later UE versions. See https://www.sandordaemen.nl/blog/cre…real-engine-4/ and https://wiki.unrealengine.com/Creati…ting_Target.cs. Or even unnecessary. See UE4 Code Modules — kantan
My question is what does step do? I thought playing with **.uproject file **is enough to hook the module with the project. Then what does that ExtraModuleName command does and how this step fits in the whole picture?
For the .build.cs file, .h file and .cpp file, it seems that they are a bit easier to understand since they are isolated very good and are only related to creating and building the module itself without involving projects or whatsoever. But there are also some questions.
The first question about this section is how you use code from one module in another module. Let’s say we have module A and module B. In the header files of module A, I have included Module B in its dependency module names. Is this enough for me to use code from module B in module A?
I also came across that Module API stuff which you have to put in front of your code in one module to expose it to others. What’s the relationship of this Module API stuff with DependancyModuleNames? Do I have to have both of them to be able to use code from B in A? I’m confused
The second question is about the IMPLEMENT_PRIMARY_GAME_MODULE(<Modulename>, “<GameName>”) and IMPLEMENT_GAME_MODULE(FDefaultModuleImpl, YourModuleName
) See: https://docs.unrealengine.com/en-US/…lay/index.html and UE4 Code Modules — kantan
These two seems very similar to me and yet their argument differs a lot. In the first one, you put the module in the first and game in the second. However, in the second one, you put some class in your module in the first and your module in the second. My questions are why in the second command you have to put a class in when you are trying to implement a module, which is sort of a collection of classes as a whole. Why single out that class? What purpose does it serve?
In the official document https://docs.unrealengine.com/en-US/…lay/index.html, it also talks about playing with the DefautEngine.ini file, which is never mentioned in other sources. What does playing with this file does when you are adding a module? Is it playing with it deprecated already?
This is a long post with many questions. I’m sorry for that and hope you guys can help me out.