Component's settings will not show in details panel if component is declared using Macro

I declared a Macro to remove some of the boilerplate code that comes with declaring components. Here’s the Macros:

#define DECLARE_COMPONENT(TYPE,NAME) \
	private: \
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Draco|Character", Meta = (AllowPrivateAccess = "true")) \
	TObjectPtr<TYPE> NAME;

#define DECLARE_GETTER(TYPE,NAME) \
	public: \
	FORCEINLINE TYPE* Get##NAME##() const { return NAME; }
	
#define DECLARE_COMPONENT_WITH_GETTER(TYPE,NAME) \
	DECLARE_COMPONENT(TYPE,NAME) \
	DECLARE_GETTER(TYPE,NAME)

When I use it like this:

	DECLARE_COMPONENT_WITH_GETTER(UCameraComponent, CameraComponent)

And create a blueprint of the c++ class, here’s how the component looks like in blueprint:

Is this expected?

Assuming this hasn’t change in UE5, Unreal Header Tool (UHT) parses your code before the preprocessor runs and generates a bunch more files and code for all the U* macros (UCLASS, UPROPERTY, UFUNCTION etc.). However if the UPROPERTY macro is hidden behind another macro UHT won’t see/recognize it and not generated the necessary code for the property. I’d guess the Blueprint Editor still shows the component by looking at the components that are present on the Class Default Object (or some other instance, maybe the preview Actor for the Editor) instead of actually looking at any properties of the class. So yes, I’d expect the macro to not work.

1 Like