Blueprints in a packaged game

Hello, i saw a lot of forum topics about this and no one helped me. I just want to understand a few things:

  1. Why Unreal has 2 ways to load objects: from constructor and from any place in code? If we have the second one why do we need those who can load only from constructors?
  2. What is really happening with assets in packaged game? Is the path to an asset is still valid or not?

i’m using this code for loading asset and it looks very simple…

UObject* cls = StaticLoadObject(UObject::StaticClass(), nullptr, path);
	if (!cls)
	{
	//handle error
	}

where path is in this format:

TEXT("WidgetBlueprint'/Game/SomeFolder/SomeWIdget.SomeWidget'")

I tried path without WidgetBlueprint’ and with _C - nothing helped. And the worst thing is even if i will find the solution i’m not sure abount will i know why exactly it works like this cause i found no docs about this rules…can someone help with this question?

P.S. Loading works in a “Development Editor” mode, but not in the others

Hello Arkirito,

When it comes to the two ways to load objects, the reason for having both methods is due to how efficient the two are. Loading something in the constructor is more efficient but only when you will be using it immediately. Loading things at runtime is better when you don’t need it until a certain point.

As for the assets and their paths; The paths by themselves are no longer valid when using a pak file in your packaged game as all of the files are contained in that pak file. I’m not completely familiar with how the structure works, but from what I understand you need to mount the pak file and then use the normal file paths along with the pak file to get the asset’s location. You can find some users talking about that very topic at this thread.

Please let me know if this explains what you needed to know or if you need more information.

Thank you, i’ll read the topic that you sent. My problem was solved, as i understand i used StaticLoadObject, i changed it to StaticLoadClass with a few little changes and looks like now it works) And i added _C, so as i can see _C should be added to load a class, if I’m right…