I can't get certain fields to show up in my editor

I’m confused onto why certain declarations allow me to see them in my Blueprint Editor and some do not. Here are examples, if anyone could tell me what I’m doing wrong that’d be great. Using Unreal 5.1

These declarations work and show up in editor:

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Stuff)
TObjectPtr<UAnimMontage> AnimationToPlay;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Stuff)
TObjectPtr<UBehaviorTree> JustABehaviorTree;

But these don’t work and won’t show up in my editor:

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Stuff)
TObjectPtr<UStaticMeshComponent> JustAMeshObject;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Stuff)
TObjectPtr<UBoxComponent> JustABoxObject;

I’m also making sure I have their header files included as well.

instead of TObjectPtr<>, could you try

UStaticMeshComponent* JustAMeshObject;

Maybe components and TObjectPtr don’t work correctly? just a guess.

I’ve also tried:

UStaticMeshComponent* JustAMeshObject;
UBoxComponent* JustABoxObject;

Still doesn’t work, I’ve tried rebuilding my solution and restarting editor etc.

For the components, did you actually create them and assign them in the Constructor?

// In the Constructor of the class

JustAMeshObject = CreateDefaultSubObject<UStaticMeshComponent>(TEXT("JustAMeshObject"));

JustABoxObject = CreateDefaultSubObject<UBoxComponent>(TEXT("JustABoxObject"));

I created my components through Blueprint instead of the constructor? Is that not allowed?

Depends, where are you expecting the component variables to show up?

To be specific, I have a weapon mesh object that I added through the Blueprint Editor using the “Add” button. I now want my C++ class to know that reference so I’m assuming I should be able to create a reference field in C++, so I can drag and drop it into the field like what I am doing with my UAnimationMontage. Fairly new to Unreal, lemme know if this is not allowed and if I should create the object through the constructor instead.

Ok, I don’t think you can drag and drop the Component to the variable. You’ll have to set it on Begin Play (There’s probably other ways that I don’t know. Also, don’t forget to change BlueprintReadOnly to BlueprintReadWrite for the component variables.)

Gotcha, ok thank you :+1:

1 Like