Hi, I used GetAssetsByPath in the editor and it can search the directory successfully. But when I use command line to open the project, there’s nothing will be found. Is there any way to solve it?
Thanks.
Not sure which one did you mentioned? I have no idea if it’s IAssetRegistry::GetAssetsByPath which included in runtime module. May need more details.
Hi, I think it is.
This is the module I use, and in game mode if I print the length of the asset data array it will be 0. But in Editor it works well, which is weird.
Afaik this is an issue with the standalone mode in editor build, which does not happen in editor itself or in shipping build.
I’d also appreciate some insight if anybody knows.
Or maybe I’ll report back if I get some time to look into it.
Can’t figure out if there’s a setting to do this properly, the Editor probably does a directory scan during startup, which standalone mode doesn’t do.
In cooked versions, the game loads a pre-baked AssetRegistry.bin on startup which is much faster.
The bin is not available in editor builds.
Here’s my bandaid fix :
#include "AssetRegistry/IAssetRegistry.h"
#include "Misc/PackageName.h"
class FMyGameModule : public FDefaultGameModuleImpl
{
virtual void StartupModule() override
{
// In standalone mode in editor build (when right-click .uproject and select Launch game)
// the AssetRegistry does not automatically scan for some odd reason.
// Try to isolate this specific case and apply bandaid fix
#if WITH_EDITOR
if (!GIsEditor && !IsRunningCommandlet())
{
TArray<FString> ContentPaths;
FPackageName::QueryRootContentPaths(ContentPaths);
//NOTE: Longest scan is "/Engine/", followed by "/Game/" and "/Niagara/"
// if others are not needed, scan only "/Game/" to gain time
const auto t = FPlatformTime::Seconds();
IAssetRegistry::Get()->ScanPathsSynchronous(ContentPaths);
UE_LOG(LogLoad, Log, TEXT("AssetRegistry ScanPathsSynchronous took %f seconds"), FPlatformTime::Seconds() - t);
}
#endif
}
};
IMPLEMENT_PRIMARY_GAME_MODULE(FMyGameModule, MyProject, "MyProject");
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.