Working with ActorComponents and SceneComponents in Unreal Engine is part of the standard workflow. Unreal, however, lacks any real tools to manage inter-component dependencies. This plugin seeks to remedy that and provide a solid solution to confirm dependencies at editor-time, easily.
To install this plugin project-local:
- Clone or download this repository (or the Release)
- In your game project folder, create a
Pluginsfolder if you don't already have one:
MyGameProject/
--> Plugins/
- Copy the
Source/CompDepfolder into your plugins folder:
MyGameProject/
--> Plugins/
----> CompDep/
------> CompDep.uplugin
------> ...
- Launch or restart the editor
- In the plugins window, find
CompDepand make sure it's enabled - Click
Restart Nowif prompted
A component may depend on other components using this library. There are 4 dependency types:
AnyOnActor: The actor this component is on needs the given dependency component type somewhere on itAnyOnActorWithTag: Same asAnyOnActor, but the dependency component also needs the given component tagChild: Only for SceneComponents. The blueprint must have a component with the given depedency component type as a child of this SceneComponentChildWithTag: Same asChild, but the given dependency component that is a child also needs the given component tag
Components may also be either Required or Optional on top of these choices.
Once you define your component dependencies, they will show up in the editor when selecting the component:
Or, in bulk, in the Dependency Viewer under CompDep > Open Dependency Viewer in the top bar:
- Create a blueprint component asset:
- Implement the
Component Dependenciesinterface in this blueprint's class:
- Implement the
Get Dependenciesinterface method, and define your dependencies in the given array:
Now when you recompile the blueprint, the dependencies will be active.
- Make sure your module lists the
CompDepmodule as dependency, either private or public:
public MyModule(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange([
"Core",
"CompDep"
]);
}- In your component class header, form your class declaration like this:
class MYMODULE_API UHealthComponent : public USceneComponent, public IComponentDependencies
{
GENERATED_BODY()
COMPDEP_DECL()
...- In your implementation file, preferably directly below your includes, define the dependencies like this:
COMPDEP_IMPL_START(UHealthComponent)
COMPDEP_DEP_ChildWithTagRequired(UAudioComponent, "health_beep_sfx")
COMPDEP_IMPL_ENDThe options for dependencies are:
COMPDEP_DEP_AnyOnActorRequired(DependencyClass)
COMPDEP_DEP_AnyOnActorOptional(DependencyClass)
COMPDEP_DEP_AnyOnActorWithTagRequired(DependencyClass, Tag)
COMPDEP_DEP_AnyOnActorWithTagOptional(DependencyClass, Tag)
COMPDEP_DEP_ChildRequired(DependencyClass)
COMPDEP_DEP_ChildOptional(DependencyClass)
COMPDEP_DEP_ChildWithTagRequired(DependencyClass, Tag)
COMPDEP_DEP_ChildWithTagOptional(DependencyClass, Tag)



