Why can't FObjectFinder be used outside constructor

By looking at the code:

https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h#L95
https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h#L12

It is designed to run early at engine initiation state, when Class Default Objects (CDOs) are created, also asset needs to be preloaded first. In other words it requires special treatment.

This might help you out on dynamic asset loading and refrenceing:

UObjectLibrary is for runtime asset interatcion:

I find this in search for anwser, this will help you out, you just need ot change functions a little as it is Blueprint example.

If any asset is loaded already (for example you already have it on level or used by object on the level), you should able to find it with normal TObjectIterator

1 Like