When we want to change the function of UE, we must change the source code and compile it. But, when we want to do this, the content we want to modify is usually just few lines code in single module, but we have to compile the whole engine !!! In this case, I think Compile the whole engine is very unnessary, is there any way could only compile the module that I want to modify?
Yes, you can only compile the specific module that you want to modify in Unreal Engine. The Unreal Build Tool (UBT) in Unreal Engine allows you to select specific modules to build and compile, instead of compiling the entire engine. This can significantly reduce the compile time, as well as allow you to focus your development efforts on the specific areas of the engine that you are modifying. To use the UBT to compile only a specific module, you will need to create a new target in your project’s Build Configuration and specify the desired module in the target’s build rules. Once you have set up your target, you can build and compile only the specific module you want to modify.
Can you say more detail please? I am still don’t know how UBT work. How to create a new target? Where should I create a new target? In a normal C++ project or project that build whole engine? I have tried at a C++ project, by copy an engine module’s source code to the project’s source folder and add build module target by using “ExtraModuleNames.AddRange” statement at “.Target.cs” file, but error occurred when I tried to build. Then I turned to modify the build setting of project that build whole engine by delete the statement “bBuildAllModules = true;” and “ExtraModuleNames.Add(“UnrealGame”);” at “UnrealEditor.Target.cs” file, but when I started to build the project “UE5”, UBT still started to compile every module.
I suggest having a look here: Build Configuration | Unreal Engine Documentation and here: Targets | Unreal Engine 4.27 Documentation
You can create a new target in your project’s Build Configuration. In Unreal Engine, you can find the Build Configuration in the project folder, typically under the “Config” or “Configurations” directory.
It’s important to note that when building a specific module, you may need to ensure that the module’s dependencies are also built and up-to-date. The Unreal Build Tool (UBT) will handle these dependencies for you automatically, but you may need to manually build the dependencies if you encounter issues.
If you are encountering errors when building a specific module, it could be due to missing dependencies, incorrect build settings, or other issues. You may need to check the Unreal Engine documentation for solutions.
I gave up. I think this should be a difficult problem, otherwise many people won’t have to compile the entire engine just for little code needs to be changed.
If you compile the entire engine once, doesn’t small changes only take a fraction of a time to compile from there on?
I haven’t compiled the entire engine, because I don’t have the patience waiting for this process to complete, and it takes up much of my computer memory, anyway, thanks for your help.
Alright then! I wish you the best of luck!
From inside the engine directory:
Build\BatchFiles\RunUBT.bat Target -Module=Module1 -Module=Module2 Platform Configuration “C:\absolute\pathto.uproject” -waitmutex
Platform is like Win64
Configuration like Development, DebugGame etc.
Each module you want to build gets passed in with -Module=.
If you’re interested in what argument options are available, they are defined in the Source\Programs\UnrealBuildTool\Configuration files like for example TargetDescriptor.cs where “-Module=” is a CommandLine attribute. Not all of the arguments are attributes though, but you can search for them by finding instances of: "-.
Thank you! this is very helpful !!!