UE4.27, 代码实践, 资源加载 FSoftClassPath / FSoftObjectPath

//以下的FSoftClassPath/FSoftObjectPath都公开在Editor里设定

 

// item in TArray<FSoftClassPath>
FSoftClassPath temp = FSoftClassPath_UsedInBluePrint_BuildFunc(item);
UClass* LoadedClass = temp.TryLoadClass<AActor>();

FSoftClassPath FSoftClassPath_UsedInBluePrint_BuildFunc(const FSoftClassPath __OriginFSoftClassPath__)
{
FString TargetPath_BuildForBP = TEXT("Blueprint'") + __OriginFSoftClassPath__.GetAssetPathName().ToString() + TEXT("'");
return FSoftClassPath(TargetPath_BuildForBP);
}


// item in TArray<FSoftObjectPath>

FStreamableManager& AssetLoader = UAssetManager::GetStreamableManager();

FSoftObjectPath temp = FSoftObjectPath_UsedInBluePrint_BuildFunc(item);

UClass* LoadedClass = AssetLoader.LoadSynchronous<UClass>(temp);

FSoftObjectPath FSoftObjectPath_UsedInBluePrint_BuildFunc(const FSoftObjectPath __OriginFSoftObjectPath__)
{
FString TargetPath_BuildForBP = TEXT("Class'") + __OriginFSoftObjectPath__.GetAssetPathName().ToString() + TEXT("_C'");
return FSoftObjectPath(TargetPath_BuildForBP);
}

posted @ 2024-03-26 11:22  在找饭吃的陈  阅读(163)  评论(0)    收藏  举报