Loading downloaded content
This commit is contained in:
parent
e751315be1
commit
3230164736
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/Actors/RuntimeLoadTest/BP_Test_RuntimeLoad.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/Actors/RuntimeLoadTest/BP_Test_RuntimeLoad.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap
(Stored with Git LFS)
Binary file not shown.
@ -21,7 +21,7 @@ namespace
|
||||
constexpr auto httpContentTypeJson = TEXT("application/json");
|
||||
|
||||
constexpr auto pakIndexUrl = TEXT("https://pixelyfier.com/lost_edge/content/");
|
||||
const auto pakFileSavePath = FPaths::ProjectDir();
|
||||
const auto pakFileSavePath = FString::Printf(TEXT("%sDownloaded/"), *FPaths::ProjectDir());
|
||||
}
|
||||
|
||||
void UContentLoader::BeginDestroy()
|
||||
@ -119,7 +119,15 @@ void UContentLoader::DownloadPak(FContentDownloadedCallback downloadedCallback,
|
||||
|
||||
FString pakToDownload = SelectContentByMethod(availablePaks, method);
|
||||
downloadedContent.Add(pakToDownload);
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Starting to download pak %s from index."), *pakToDownload);
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Pak selected for loading: %s."), *pakToDownload);
|
||||
|
||||
auto savePath = FString::Printf(TEXT("%s%s"), *pakFileSavePath, *pakToDownload);
|
||||
if(FPlatformFileManager::Get().GetPlatformFile().FileExists(*savePath))
|
||||
{
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Selected pak already exists... skipping download."));
|
||||
downloadedCallback.ExecuteIfBound(savePath);
|
||||
return;
|
||||
}
|
||||
|
||||
FHttpRequestCompleteDelegate pakDownloadCallback;
|
||||
pakDownloadCallback.BindLambda([=, this](FHttpRequestPtr request, FHttpResponsePtr response, bool successful)
|
||||
@ -132,7 +140,6 @@ void UContentLoader::DownloadPak(FContentDownloadedCallback downloadedCallback,
|
||||
return;
|
||||
}
|
||||
|
||||
auto savePath = FString::Printf(TEXT("%s%s"), *pakFileSavePath, *pakToDownload);
|
||||
if(!FFileHelper::SaveArrayToFile(response->GetContent(), *savePath))
|
||||
{
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Saving pak file %s failed."), *savePath);
|
||||
@ -143,6 +150,7 @@ void UContentLoader::DownloadPak(FContentDownloadedCallback downloadedCallback,
|
||||
downloadedCallback.ExecuteIfBound(savePath);
|
||||
});
|
||||
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Starting to download pak %s from index."), *pakToDownload);
|
||||
HttpGet(FString::Printf(TEXT("%s%s"), pakIndexUrl, *pakToDownload), pakDownloadCallback);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user