So, I am adding a SceneComponent to an another custom SceneComponent derrived class like so,
in header
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "UI Indiactor")
class UStaticMeshComponent* ButtonIndicatorComp;
in cpp
UStaticMeshComponent* IndicatorComp = ConstructObject<UStaticMeshComponent>(UStaticMeshComponent::StaticClass(), this);
//IndicatorComp->AttachTo(this);
ButtonIndicatorComp = IndicatorComp; // pointer reference to be persist throughout the game.
And it seems to work but when I try to save… below error occurred.
What would be my best bet to go over this problem?
If the construction of the component is taking place inside the class constructor then you will want to use CreateDefaultSubobject instead of ConstructObject. Additionally, since you declared the ButtonIndicatorComp in your header file, you can use this in the construction call rather than creating a new pointer and then setting the new pointer to ButtonIndicatorComp.