I am reading the documentation of Referencing Assets. Under the Find/Load Object section, the following example code are said to be able to load an asset at runtime:
GridTexture = LoadObject<UTexture2D>(NULL, TEXT("/Engine/EngineMaterials/DefaultWhiteGrid.DefaultWhiteGrid"), NULL, LOAD_None, NULL);
A file DefaultWhiteGrid.uasset comes default with the engine’s source code under **UnrealEngine\Engine\Content\EngineMaterials**. The code runs correctly at runtime, both in the Editor mode and in a development build. In a development build, how does the game executable find this file?
What’s more, I made a copy of the above file, renamed it to DefaultWhiteGrid2.uasset and replaced the above line of code to (only modify the asset name):
GridTexture = LoadObject<UTexture2D>(NULL, TEXT("/Engine/EngineMaterials/DefaultWhiteGrid2.DefaultWhiteGrid2"), NULL, LOAD_None, NULL);
The code failed to load that file at runtime. I cannot figure out the reason.