您的位置:首页 > 产品设计 > UI/UE

关于UE4动态资源加载(蓝图类)

2016-04-21 11:12 495 查看

本帖纯属个人原创,如有转载请注明出处

需要注意的几点:

1.调试环境下进行的资源加载方式到打包出来后不一定能够使用。

2.假如遇到调试模式下程序运行正常,但是打包出来后程序crash,可以查看log: Saved/Logs/filename/log

3.资源路径的代码书写格式 

map : "Game/Maps/Main.map"

蓝图类 :  "Game/Blueprint/Skill/skill_1.skill_1_C"

正常的uasset: "Game/Bluerpint/Sound/sound_1.sound_1"

通过摸索,check到如下代码:

UBlueprintGeneratedClass* FileName::GetAssetFromPath(FString AssetPath)

{
UBlueprintGeneratedClass *ParentClass = nullptr;
FStringClassReference ref = AssetPath;
UObject* uoTmp = ref.ResolveObject();
if (uoTmp == nullptr)
{
UE_LOG(LogTemp, Log, TEXT("GetAssetFromPath path = %s", *AssetPath));
FStreamableManager EKAssetLoader;
uoTmp = EKAssetLoader.SynchronousLoad(ref);
}

ParentClass = Cast<UBlueprintGeneratedClass>(uoTmp);

return ParentClass;

}


外部不管是spawnActor或者是NewObject直接传入[b]ParentClass。[/b]





如有错误还请纠正。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dynamic_create Assest