本文共 936 字,大约阅读时间需要 3 分钟。
FString strBasePath = FPaths::Combine(*FPaths::ProjectDir(), TEXT("Content/")); FString allUIFilePath = FPaths::Combine(*strBasePath, TEXT("UI/Wnd/")); TArrayallWndFilePath;IFileManager::Get().FindFilesRecursive(allWndFilePath, *allUIFilePath, TEXT("*.uasset"), true, false);
allUIFilePath = “../../../../ProjectDir/Content/UI/Wnd/TestWnd.uasset”
通过找到最后一个/和最后一个.字符可以获得文件名TestWnd
tempPath.FindLastChar('/', iFindStart); tempPath.FindLastChar('.', iFindEnd); FString strFileName = tempPath.Mid(iFindStart + 1, iFindEnd - iFindStart - 1);
可用于加载UObject的路径为
FString LoadObjectPath= tempPath.Replace(*strBasePath, TEXT("/Game/")).Replace(TEXT(".uasset"), *FString::Printf(TEXT(".%s"), *strFileName))实例:/Game/UI/Wnd/TestWnd.TestWnd
可用于加载UClass的路径为
FString LoadObjectPath= tempPath.Replace(*strBasePath, TEXT("/Game/")).Replace(TEXT(".uasset"), *FString::Printf(TEXT(".%s"), *strFileName)) + "_C";实例:/Game/UI/Wnd/TestWnd.TestWnd_C
转载地址:http://kzubf.baihongyu.com/