Download

Is it possible to disable UHT for a single file?

I wanted to create a macro to implement a common interface. I want to test how it would be to use components as much as possible.

Unfortunately that means that I would have to use


OtherActor->FindComponentByClass<UHealthComponent>();

which “could” be slow. So I want to implement a simple interface for every component.

I thought I could automate this with some macros like


#define IMPL_COMP_INTERFACE(INTERFACE,COMPONENT)\
	class U##COMPONENT;\
	UINTERFACE(MinimalAPI) \
	class U##INTERFACE : public UInterface \
	{\
		GENERATED_UINTERFACE_BODY() \
	};\
	class I##INTERFACE\
	{\
		GENERATED_IINTERFACE_BODY()\
		virtual U##COMPONENT* Get() const;\
	};\

Unfortunately


UINTERFACE(MinimalAPI) \

still gets parsed even if it is inside a macro. Is it possible to disable UHT for this file?

If that is not possible I could also auto generate the whole file directly. Any recommendations of what tools you would use to do this?

Edit:

I also think it would be enough if I could auto generate a simple interface in the editor with “Add Code to Project”. I don’t think that is possible at the moment. If you are a Epic employee would you like this as a PR?

Okay I renamed the file from ComponentHelper.h to ComponentHelper.hpp and now it doesn’t get picked up by the UHT.