x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Having C++ inherited components be editable in blueprints, when the component is declared in another component, and not in the actor itself

Hello,

I'm having some trouble getting C++ inherited components exposed to blueprints where they are editable in the details tab.

Through searching, I have learned how to expose inherited components to blueprints and have them be editable. However, I'm having problems only when the component is declared in another component, and not declared in the actor itself.

Here's the scenario:

  1. I create a C++ actor AFooActor, inherited from AActor.

  2. I create a C++ component UBarSceneComponent, inherited from USceneComponent.

  3. In AFooActor, I declare a USkeletalMeshComponent FooMesh, and a UBarSceneComponent BarScene.

  4. In UBarSceneComponent, I declare another USkeletalMeshComponent BarMesh.

  5. In both AFooActor and UBarSceneComponent's constructors, I instantiate the above components using CreateDefaultSubobject.

  6. Finally, I create a blueprint BP_Foo, inherited from AFooActor.

In this case, when I open BP_Foo in the blueprint editor, I would expect FooMesh, BarScene, and BarMesh all to be exposed and editable with the details tab. However, only FooMesh and BarScene, which are declared directly in the actor, are editable. BarMesh, which is declared in UBarSceneComponent and not in the actor, is not editable.

Below are screenshots and code to illustrate.

AFooActor

 // Header
 #pragma once
     
 #include "CoreMinimal.h"
 #include "GameFramework/Actor.h"
 #include "FooActor.generated.h"
     
 UCLASS()
 class MYAPPLICATION_API AFooActor : public AActor
 {
     GENERATED_BODY()
 
 public:
     AFooActor();
     AFooActor(const FObjectInitializer& ObjectInitializer);
 
 public:
     // Declare FooMesh
     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Foo")
     class USkeletalMeshComponent* FooMesh;
 
     // Declare BarScene
     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Foo")
     class UBarSceneComponent* BarScene;
 };
 
 // Constructor
 AFooActor::AFooActor(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
 {
     // Works; FooMesh is visible in the blueprint, and the details panel is fully exposed and editable
     this->FooMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("FooMesh"));
 
     this->BarScene = ObjectInitializer.CreateDefaultSubobject<UBarSceneComponent>(this, TEXT("BarScene"));
 }


UBarSceneComponent

 // Header
 #pragma once
 
 #include "CoreMinimal.h"
 #include "Components/SceneComponent.h"
 #include "BarSceneComponent.generated.h"
 
 UCLASS(ClassGroup = (FooBar), meta = (BlueprintSpawnableComponent))
 class MYAPPLICATION_API UBarSceneComponent : public USceneComponent
 {
     GENERATED_BODY()
 
 public:
     UBarSceneComponent();
     UBarSceneComponent(const FObjectInitializer& ObjectInitializer);
 
 public:
     // Declare BarMesh
     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Bar")
     class USkeletalMeshComponent* BarMesh;
 };
 
 // Constructor
 UBarSceneComponent::UBarSceneComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
 {
     // NOT editable; I can see BarMesh in the blueprint, but the details panel is empty and cannot be edited
     this->BarMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("BarMesh"));
 }


Screenshots of the BP_Foo blueprint are attached. FooMesh and BarScene are exposed and editable. BarMesh is exposed, but not editable.

So my question is, what is the best way to have components declared within components be editable in the blueprint just like those declared in the actor? Is what I'm trying to do possible? I suspect I have some fiddling to do with the UPROPERTY fields, but so far I haven't found a solution.

Any help is appreciated. Thanks in advance.

Product Version: UE 4.18
Tags:
ss-foomesh.png (39.9 kB)
ss-barscene.png (34.2 kB)
ss-barmesh.png (19.6 kB)
more ▼

asked Feb 13 '18 at 07:05 AM in C++ Programming

avatar image

rbgr10
11 1 1 3

avatar image Dexgecko Jul 01 '18 at 04:32 PM

How did you even get foomesh to be editable? I thought inherited components were completely uneditable? EDIT: I see it's in the declaration macro. This was really informative, thanks.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Looking at my setup again, I just realized that the details for BarMesh seem to be included in the details panel for the BarScene component (as shown in the attached ss-barscene.png). It's just not in the details panel for BarMesh, where I would have expected.

This certainly addresses my problem, and I feel a bit silly for not noticing this off the bat, but I suppose this is the intended behavior?

more ▼

answered Feb 14 '18 at 05:13 AM

avatar image

rbgr10
11 1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question