How to declare Only c++ UPROPERTY Specifier

Hi,

I have some properties that are only accessible via C++. So they don’t need to be accessible by blueprints.

After reading what the documentation says about Properties, I used “Native” but I got “Unknown variable specifier Native”.

UPROPERTY(Native, Category = Achilipu)
UMaterial* MasterMaterial;

How can I properly define a property that is not going to be accessed by blueprints nor the editor but I still want it to be handled by the garbage collector?

Many thanks.

There’s a full page on the Wiki about UObjects, dynamic allocation and the UE4 Garbage Collector, you can find it here.

A snippet from the article (in case the link ever breaks or changes):

UE4 Garbage Collection only counts references to UObjects that are UPROPERTY()

Which you can delcare in your header:

UPROPERTY()
UMyObjectClass* MyGCProtectedObj;

And instantiate (in your CPP):

MyGCProtectedObj = NewObject<UMyObjectClass>(this);

Note the UPROPERTY() Macro declaration with no parameters.

Hope that helps :slight_smile:

Thanks. Yes, it works.

Nice article, :slight_smile: