<aside> 🗒️ Part of Ari's Unreal Engine Notes.

</aside>

This presentation covers everything about modules and more.

This presentation covers everything about modules and more.

Build

Create a .Build.cs file that builds the module.

using UnrealBuildTool;

public class FooBar : ModuleRules
{
  public FooBar(ReadOnlyTargetRules Target) : base(Target)
  {
     PrivateDependencyModuleNames.AddRange(new string[] {"Core"});
  }
}

Use

Expose classes to the engine via UCLASS/UPROPERTY/UFUNCTION specifiers.

Optionally use UCLASS(MinimalAPI) to also expose minimal information to other modules, enough to cast to the class.

Expose functions or classes to code in other modules with FOOBAR_API (use your module name in all caps instead of FOOBAR) in header files in your module's /Public folder.

UCLASS(Blueprintable)
class FOOBAR_API AExampleActor: public AActor
{
	GENERATED_BODY()
	// Rest of the class
};

Implement

Call IMPLEMENT_MODULE after any declarations in [YourModuleName]Module.cpp.

#include "Modules/ModuleManager.h"
IMPLEMENT_MODULE(FDefaultModuleImpl, FooBar);

Load

Add a module descriptor to your .uproject or .uplugin file.

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

Depend

Only modules in the dependency chain get compiled.

If another module should depend on your module, add it to that module's .Build.cs file.

PrivateDependencyModuleNames.AddRange(new string[] {"Core", **"**FooBar**"**});
// or PublicDependencyModuleNames, if FooBar is used in this module's public headers.