x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UE4 Custom Pak load

Hello,

I got a problem when loading assets from .pak from builded application.

This is my workflow:

1 - Import 3D model (fbx + texture), so in my project I got:

  • material.uasset

  • skeletalMesh.uasset

  • physicsAsset.uasset

  • skeleton.uasset

  • texture.uasset


2 - I pak all these assets into a pak file with UnrealPak command line:

UnrealPak.exe ".path/to/6737.pak" -Create="path/to/filesToPak.txt" -encryptionini -platform=Windows -installed -UTF8Output -multiprocess -patchpaddingalign=2048 -abslog="path/to/6737.log"


3 - Unreal process:

  • Mount pak to path

  • Find files in MountPoint (files found with success)

  • Load files


This code work in Editor perfectly. I can load and build my character but when builded for Windows platform, I got this error when I try to load uasset:

Warning: Unable to load package (../../../UE4PakFiler/Content/UNPAK/6737_M.uasset). Package contains EditorOnly data which is not supported by the current build.


Code:

 void UMyClass::TestLoad(TArray<UObject*> &Classes)

{

     IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
     FPakPlatformFile* PakPlatformFile = new FPakPlatformFile();
     PakPlatformFile->Initialize(&PlatformFile, TEXT(""));
     PakPlatformFile->InitializeNewAsyncIO();
     FPlatformFileManager::Get().SetPlatformFile(*PakPlatformFile);
 
     const FString PakFilename = TEXT("C:\\Users\\MAX\\Desktop\\CustomPak\\6737.pak");
     FPakFile PakFile(&PlatformFile, *PakFilename, false);
 
     if (PakFile.IsValid())
     {
         UE_LOG(LogClass, Warning, TEXT("===== Pak file is valid ====="));
     }
 
     
     FString MountPoint = "";
 #if WITH_EDITOR
     MountPoint = FString("E:/Silkke/UE4/UE4PakFiler/Content/UNPAK");
     //MountPoint = FPaths::ProjectContentDir() + "UNPAK";
 #else
     //MountPoint = FPaths::ProjectPersistentDownloadDir();
     MountPoint = FPaths::ProjectContentDir() + "UNPAK";
 #endif
     PakFile.SetMountPoint(*MountPoint);
 
     if (!PakPlatformFile->Mount(*PakFilename, 0, *MountPoint))
     {
         UE_LOG(LogClass, Warning, TEXT("Mount failed"));
         return;
     }
 
     UE_LOG(LogClass, Warning, TEXT("===== Pak mounted with success '%s' ====="), *PakFilename);
     UE_LOG(LogClass, Warning, TEXT("FileName: %s"), *PakFilename);
     UE_LOG(LogClass, Warning, TEXT("Mountpoint: %s"), *PakFile.GetMountPoint());
 
     TArray<FString> FileList;
     PakFile.FindFilesAtPath(FileList, *PakFile.GetMountPoint(), true, false, true);
     FStreamableManager StreamableManager;
 
     UE_LOG(LogClass, Warning, TEXT("Files found: %d"), FileList.Num());
     if (FileList.Num() > 0)
     {
         UE_LOG(LogClass, Warning, TEXT("Files browse..."));
 
         for (auto f : FileList)
         {
             FString AssetShortName = FPackageName::GetShortName(f);
             FString LeftStr;
             FString RightStr;
             AssetShortName.Split(TEXT("."), &LeftStr, &RightStr);
             //FString AssetName = FPaths::ProjectPersistentDownloadDir() + "/" + LeftStr + TEXT(".") + LeftStr;
             FString AssetName = TEXT("/Game/UNPAK/") + LeftStr + TEXT(".") + LeftStr;
             //FString AssetName = TEXT("/Game/6737/") + LeftStr + TEXT(".") + LeftStr;
 
             UE_LOG(LogClass, Warning, TEXT("AssetName: %s"), *AssetName);
 
             FStringAssetReference r = AssetName;
             UObject* LoadObject = StreamableManager.LoadSynchronous(r, true);
 
             if (LoadObject != nullptr)
             {
                 UE_LOG(LogClass, Warning, TEXT("Asset loaded with success: %s"), *AssetName);
                 Classes.Add(LoadObject);
             }
             else
             {
                 UE_LOG(LogClass, Warning, TEXT("Asset failed to load: %s"), *AssetName);
             }
         }
     }
 
     if (PakPlatformFile->Unmount(*PakFilename))
         UE_LOG(LogClass, Warning, TEXT("===== Pak unmounted with success '%s' ====="), *PakFilename);
 }



If someone can help me ? :)

Thanks,

~Nyudeb

Product Version: UE 4.21
Tags:
more ▼

asked Apr 19 '19 at 09:54 AM in Packaging & Deployment

avatar image

nyudeb
21 2 5 7

avatar image nyudeb Apr 24 '19 at 08:50 AM

I found that the problem was how to package my assets... When I create a pak from the editor (build), I can load them. But when I create the pak via UnrealPak, something must be missing that makes the assets usable only via the Editor....

avatar image okynorch Apr 26 '19 at 07:23 PM

Same issue here, however if you set the build configuration to Shipping, there is no errors but it does not load the asset from the pak file. I tried to create the pak file from the editor, but that I am still not able to load the asset at runtime.

avatar image nyudeb Apr 29 '19 at 08:20 AM

I found the solution. You need to cook .uasset you want to use in Dev / Ship build. And you just need to drag'n'drop asset in editor + pak them to use them in Editor. So finally, you need 2 different .pak: cooked and uncooked

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question