Is there a definitive way to have a component of a component in c++?
I am working on creating a variety of nested functionality through components and per-wrapped component trees. For example, I want a component that can bring in a box collider and a text render in the same component.
USceneComponents can have other USceneComponents attached to each other as children; those children can be modfied in the details panel of an object.
The Unreal documentation describes them as:
In the approach you mention, it makes sense to define some public interface for all components that you want to be using in a modular way. However note that scene components generally speaking are supposed to show some scenery. As you are trying to add configurable modularity to your project: I once had the same task at hand and I can provide you with a way I solved it - below.
You create one actor component that adminsters the entire system you are currently implementing; let's call it UMySystemComponent. To it you can add modules. When an actor wants to use your system, you add the component to it and add specific modules. To define a module let's create a class, I will call it UConfigurableModule for reference, that defines the basic interface required by any module, for instance a UFunction named Callback(); UConfigurableModule should inherit from UObject from a design perspective but due to engine bugs (which I reported here) it must temporarily inherit from UActorComponent until it's fixed. The class specifiers of UConfigurableModule shall be Blueprintable, BlueprintType and EditInlineNew. In UMySystemComponent, add a TArray as property and make sure it has the specifiers EditAnywhere and Instanced. Now, your level designers can specify classes for components in your UMySystemComponent and configure their propertiers right in the details panel of UMySystemComponent. Da-da
Follow this question
Once you sign in you will be able to subscribe for any updates here