FObjectFinder vs LoadObject

Let’s collect the differences between the two methods, as they don’t seem to be mentioned anywhere else.

FObjectFinder is used in constructor, while LoadObject is used anywhere

2.

Syntax difference:


UMaterial* material_var = LoadObject<UMaterial>(nullptr,TEXT("Material'/Game/...'"));
//vs
static ConstructorHelpers::FObjectFinder<UMaterial> material_wrapped(TEXT("Material'/Game/...'"));
UMaterial* material_var = material_wrapped.Object;
3.

FObjectFinder creates a static var in C++ constructor which wastes sizeof(*ptr) of RAM per class for each time you use that method

I will add more differences as i discover them either myself or hear them here.

one particularly interesting is how slower is LoadObject compared to FObjectFinder?

I get an access violation error when using the FObjectFinder in the constructor of one class. Have you got any idea what the reason for that might be?
The line is

auto psAsset = ConstructorHelpers::FObjectFinder<UParticleSystem>(TEXT("ParticleSystem'/Game/ParticleSystems/PS_CompoundCloud_SingleCelled.PS_CompoundCloud_SingleCelled'"));

Thanks for the help.

are you getting the error when trying to reference psAsset later in code, or in this very line?

sadly i don’t have a clue on what could cause it. the only thing i would suggest is double checking you call it in the classic C++ MyClass() constructor, rather than OnConstruction()

otherwise i would submit a separate question here in AnswerHub

just keep bumping the question every 4-7 days. eventually you will get an answer. just please don’t bump too much because it would be selfish :]

In that exact line and if I try FObjectFinderOptional I get it on Succeeded() and Get()

I tried it in different constructors, in different classes. For some reason it only happens with particle systems. And I already posted a question two days ago and so far haven’t got any answers so I thougt I might look around.

Thank you so much

no problem mate, enjoy

Well, apparently loading a Skeletal Mesh in the constructor with LoadObject ignores its virtual bones