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"

Mounting pak files at runtime

Hi guys, Im using this plug in to mount pak file at runtime - https://github.com/moritz-wundke/AsyncPackageStreamer

The plugin compiles with no issues and can be used on UE4.7.2, what I'm trying to do is stream a local pak file, this is my code:

 UTestSingletonClass* dataInstance = Cast<UTestSingletonClass>(GEngine->GameSingleton);
 FAssetStreamer *obj = new FAssetStreamer();
 obj->Initialize(&dataInstance->AssetLoader);
 obj->CurrentMode = EAssetStreamingMode::Type::Local;
 FString pakFile = TEXT("Out.Pak");
 FString args = TEXT("-pakdir=");
 args += FPaths::GameContentDir() + TEXT("/Paks");
 obj->StreamPackage(pakFile, this, EAssetStreamingMode::Type::Local,*args);

but the engine crashes due to a null pointer exception on this class FPakPlatformFile::FindAllPakFiles, Im not sure if I'm using the plug in correctly or not, does anybody have used such plug in before ??

thanks in advance.

Product Version: Not Selected
Tags:
more ▼

asked Mar 17 '15 at 03:21 PM in C++ Programming

avatar image

hugomj
16 1 2 2

avatar image zetarus Jul 30 '15 at 12:14 PM

I'm suffering a same problem. Is there any people that have used AsyncPackageStreamer plugin?

avatar image 小清清问 Jan 06 '16 at 08:17 AM

Me too ,Who can help us

avatar image Muzaheed Apr 17 '16 at 02:29 AM

did anybody have any success?

avatar image yunxiang Apr 19 '16 at 07:11 AM

Same issue here. Try to use asset from server by this method. Hope someone do a video or something about how to use asset from server by PAK file method.

Sam

avatar image indusninja Apr 21 '16 at 12:38 PM

I'm getting the same exception:

 Exception thrown: read access violation.
 LowLevelFile was 0xFFFFFFFFFFFFFFFF.
 If there is a handler for this exception, the program may be safely continued.
 >    UE4Editor-PakFile.dll!FPakPlatformFile::FindAllPakFiles(IPlatformFile * LowLevelFile, const TArray<FString,FDefaultAllocator> & PakFolders, TArray<FString,FDefaultAllocator> & OutPakFiles) Line 588    C++
      UE4Editor-PakFile.dll!FPakPlatformFile::Initialize(IPlatformFile * Inner, const wchar_t * CmdLine) Line 671    C++
      UE4Editor-AsyncPackageStreamer.dll!FAssetStreamer::UseLocal(const wchar_t * CmdLine) Line 151    C++
      UE4Editor-AsyncPackageStreamer.dll!FAssetStreamer::StreamPackage(const FString & PakFileName, IAssetStreamerListener * AssetStreamerListener, EAssetStreamingMode::Type DesiredMode, const wchar_t * CmdLine) Line 65    C++
      UE4Editor-DynamicAssetLoad.dll!UTestWidget::OnLoadPakClick() Line 63    C++
      UE4Editor-DynamicAssetLoad.dll!UTestWidget::Pak_HttpRequestComplete(TSharedPtr<IHttpRequest,0> HttpRequest, TSharedPtr<IHttpResponse,1> HttpResponse, bool bSucceeded) Line 52    C++

I'm following the guidelines described by hugomj_ca about the PAK file creation (PAK from WindowsNoEditor cooked uassets):

If anyone's interested, they can take a look at my code.

avatar image Muzaheed Apr 21 '16 at 04:09 PM

same. hugomj_ca's sample pak did not help. always crashing at " LowLevelFile".

ue4.10.3

i am felling that either the address have someting to do or the code work only on older version

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

5 answers: sort voted first

i have found the solution of crash problem. a variable was wrongly initiaintialized. because of wrong value LowLevelFile value assignment operation always was skipped . thats why it was always null and always was crashing. now i have to check if pak file successfully get mounted. if it works now then i will post the fix until then dont waste your time to make the plugin work. it will always crash.

more ▼

answered Apr 24 '16 at 08:37 AM

avatar image

Muzaheed
240 18 24 31

avatar image indusninja Apr 25 '16 at 06:55 AM

you're probably going to run into this problem after mounting the pak file correctly.

avatar image Muzaheed Apr 25 '16 at 09:45 AM

yup. already started dealing with that since yesterday. i have figure out a solution. but it is getting delayed because it turns out that plugin has another issue with mounting point. excellent plugin. but most probably developer did not use this exact version. so 2/3 issue never was noticed by him.finding and fixing them is taking time.

avatar image Mohsan Apr 04 '17 at 11:34 AM

@muzaheed: Were you able to fix this crash issue?

avatar image Muzaheed Apr 04 '17 at 07:47 PM

Yup. But i am no.longer using the plugin. I extracted code from it and craeted own version . It worked fine untill 4.15 In 4.15 epic dis something pak.mounting ayatem which is making all the assets of contents folder unaccessible after u call mount() .

avatar image Mohsan Apr 05 '17 at 07:06 AM

Could you guide me how did you fixed it or send me a codesnip to resolve it?

avatar image theonecalledtom May 03 '17 at 03:52 PM

@Muzaheed I've just run into the 4.15 issue where mounting a pak prevents assets in the content folder from loading - in my case levels.

Did you find a solution?

avatar image Muzaheed May 03 '17 at 04:50 PM

sorry. same on my side.i decided to stick with 4.14 for now.

avatar image theonecalledtom May 03 '17 at 05:41 PM

blargh.

:)

avatar image theonecalledtom May 06 '17 at 01:35 AM

Set EXCLUDE_NONPAK_UE_EXTENSIONS = 0

avatar image Muzaheed May 09 '17 at 08:47 AM

ooow. thanks man. i belief setting "EXCLUDE_NONPAK_UE_EXTENSIONS = 0 " will solve the assets content loosing problem

avatar image masmil1988 Nov 28 '17 at 04:18 PM

Where do I have to set EXCLUDE_NONPAK_UE_EXTENSIONS?

avatar image theonecalledtom Nov 28 '17 at 04:30 PM

Search for it in the engine code (platform file.cpp? Not at computer).

Last I checked you still needed to do a full engine source build to do this. It's not too bad once done but adds significant overhead.

avatar image masmil1988 Nov 28 '17 at 04:52 PM

Ok, I imagined it was possible to modify it in another way since the comment on that row says "Use .Build.cs file to disable this if the game relies on accessing loose files"

Anyway...!

avatar image theonecalledtom Nov 28 '17 at 04:58 PM

Technically that statement is correct. However when I experimented with that it didn't work the first time I compiled (but did kick in on a later compile), so I didn't suggest it. Didn't seem to be much advantage as the build file was in the engine source already [I might be missing something here but defining it in my own project did nothing and this makes sense as implemented it's use needs to modify engine code so you need to be compiling engine code].

Honestly I prefer my suggested solution which is still sitting in la la land:

https://github.com/EpicGames/UnrealEngine/pull/3548

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

did anybody have any success?

more ▼

answered Apr 17 '16 at 02:28 AM

avatar image

Muzaheed
240 18 24 31

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

Pak file generation :

Cooked vs un-Cooked content

cooking means you need process your assets and optimize them for your target platform, uncooked assets are not optimized and intended to work only for development under UE4 editor.

if you are working on a development build you create the pak files using *.uasset files from the editor using unrealPak.exe as follows:

Command line argument - [path+executable] [location of desired pak+name.pak] –create=[location of pak list file.txt] -compress

Example :

d:/ue4/Engine/Binaries/Win64/UnrealPak.exe //someSharedAssetFolder/SomeProject/Pak/SomeAwesome.pak -create=d:/temp/filesListToProcess.txt –compress

On the other hand if you want to use pak files on stand alone builds you need to cook the contents for your target platform for example Windows / Linux / iOS / PS, etc. Cooked folder is normally found at: \Cooked\WindowsNoEditor\YourProjectName\Content\Assets\

if the folder is empty or does not exists is because you havent "cooked" the contents for the target platform, and you can do it within the editor, just go to File menu and click "Cook contents for [Target Platform]"

NOTE: To avoid confussions you should name you pak files according to the target:

• If the list is generated from editor.uassets, then the pak file should end with _Editor.pak

• If the list is generated from cooked file assets, then the pak file should end with _Standalone.pak.

Editor or "uncooked" content wont work with Stand Alone / Distribution / Shipping builds

Using the plugIn

1) Create a folder called "Plugins" at the root level of your game

2) Copy the contents of AsyncPackageStreamer into it, the file structure should look like this: • YourGame\Plugins\AsyncPackageStreamer

3) Verify if it's correctly installed by opening UE4 Editor go to Window Menu --> PlugIns --> Project (Async Package Streamer should be listed there) also when opening the editor for the first time it should start compiling the plugIn

4) Add a reference to YourProjectName.Build.cs (located at the root level of the solution) to include the plugin Headers into the compilation process:

  PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", 
                                                             "Slate", "SlateCore", "HTTP", "Json", "JsonUtilities", "MoviePlayer",
                                                             "PakFile", "Sockets","StreamingFile",  "NetworkFile",
                                                              "AsyncPackageStreamer",....
                                                          

5) Create a class somewhere a Test widget will be enough for testing and include the AsyncPakage streamer header file:

 #include "AssetStreamer.h"
 
 #include "TestWidget.generated.h"
 
 /**
  * Sample class for testing button click callbacks and service callbaks
  */
 UCLASS()
 class VSPEC_APP_API UTestWidget :  public IAssetStreamerListener  // implement AsyncAssetStreamer Interface
 {
     GENERATED_BODY()
     
 public:
     
     UTestWidget(const FObjectInitializer& ObjectInitializer);
 
     void OnAssetStreamComplete();            // AsyncPakage Streamer abstract Method
     void OnPrepareAssetStreaming(const TArray<FStringAssetReference>& StreamedAssets); // AsyncPakage Streamer abstract Method
     
     UFUNCTION(BlueprintCallable, Category = "Click Handlers")
     void OnLoadPakClick();
     
 private:
     UPROPERTY(EditAnywhere, Category = "Dynamic Loaded Content")
     TArray<FStringAssetReference> MyStreamedAssets;

     FStreamableManager streamableManager;   // Engine StreamManager Instance
     ......
     
 

6) Implement IAssetStreamer methods

 void UTestWidget::OnLoadPakClick()
 {
     FAssetStreamer *assetStreamer = new FAssetStreamer();
     assetStreamer->Initialize(&this->streamableManager);
     assetStreamer->CurrentMode = EAssetStreamingMode::Type::Local;
     FString pakFile = "C:\MyAwesomePak"; 
     assetStreamer->StreamPackage(pakFile, this, EAssetStreamingMode::Type::Local, TEXT(""));
 
 }
 
 void UTestWidget::OnPrepareAssetStreaming(const TArray<FStringAssetReference>& StreamedAssets)
 {
     MyStreamedAssets = StreamedAssets; // Prepare a local reference of the assets to be streamed 
 }
 
 void UTestWidget::OnAssetStreamComplete()
 {
     for (int32 i = 0; i < MyStreamedAssets.Num(); ++i)
     {
         check(Cast<UTexture2D>(MyStreamedAssets[i].ResolveObject()) != nullptr); // you have to cast to the exact type Texture2d, StaticMesh, etc...
     }
 }




more ▼

answered Apr 18 '16 at 09:42 PM

avatar image

hugomj_ca
6 1 1

avatar image Muzaheed Apr 18 '16 at 11:18 PM

which engine version you were using ? I was having crush on 4.10 and 4. 11 . Although that was my own implementation. I will try out yours one today. thanks for the tutorial.

avatar image hugomj_ca Apr 19 '16 at 02:26 PM

I been using this approach since UE4.7 now I'm using UE4.10 and still works as intended

avatar image Muzaheed Apr 21 '16 at 04:13 PM

is it 4.10.3 ?

avatar image Malloc007 Sep 08 '16 at 06:59 AM

Hello,I'm according to your aboves steps ,but not sucess. Could you can give a little demo,Thank you ,my unreal engine version is 4.12

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

hugomj_ca and mfish, we appreciate your time and effort to answer all these amateur questions. But most of us having no luck. for reference, Can u guys post a proper pak file which is working fine on your side? Using that pak we at least we can figure out where the problems lies on our side. On cooking process or in Code.

Thanks.

more ▼

answered Apr 19 '16 at 03:27 PM

avatar image

Muzaheed
240 18 24 31

avatar image hugomj_ca Apr 19 '16 at 05:25 PM

Sure, attached you can find 2 pak files, one for Editor (uncooked) and one for stand alone builds (Cooked for Windows (PC)), the contents are a bunch of textures -- Flag textures to be precise --

Sample Pak

Note: Is always better to work using the full source code of the engine, not the binary build, in that way you can see the full stack trace and figure out issues as they come in a more verbose way.

Hugo.

samplepak.zip (106.8 kB)
avatar image 咔咔_虚 Oct 25 '16 at 10:33 AM

how to make stand alone pak as you? I make shipping pak by edit -- cooked for windows, but I don't load it correct. 304775992@qq.com

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

The way I solved this problem, assuming the pak file was setup correctly, was to load a local pak file with the following code:

 if (FCoreDelegates::OnMountPak.IsBound()) {
      FCoreDelegates::OnMountPak.Execute(PakPath, 4); //Number should be 0-4; specifies search order
 }

Where PakPath is an FString that points to the location of your pak file. Once you load in the pak file you can access the maps and other assets from within the pak file the same way you would if they had been packaged with your game.

more ▼

answered Jul 30 '15 at 07:35 PM

avatar image

mfish
31 1 2 4

avatar image zetarus Jul 31 '15 at 05:54 AM

Hi, I'm tring to load a PAK file for my game(in case, I have used the TopDown project) But, I have failed to load a PAK file.

  1. I made a "MyPlayer" blueprint class from Character BP at "Content/TopDown/Blueprints/MyPlayer.uasset"

  2. Made a PAK file for my new asset using UnrealPak.exe. ->E:\GitHub\UnrealEngine\Engine\Binaries\Win64\UnrealPak.exe F:\BAK\MyProject\Content\Paks\Output.pak -create=F:\BAK\MyProject\Saved\PakList_pakchunk0-Android_ETC1.txt

Content of "PakList_pakchunk0-Android_ETC1.txt" is below "F:\BAK\MyProject\Content\TopDown\Blueprints\CHAR\MyPlayer.uasset" "......\Engine\Content\MyPlayer.uasset" -compress

  1. Run UnrealFileServer.exe

  2. My client code loads that Pak file. FString PakFile = FPaths::GameContentDir() + FString(TEXT("Paks/")) + "Output"; FString Args = TEXT("-pakdir="); Args += FPaths::GameContentDir() + TEXT("Paks/"); ExpansionAssetStreamer->StreamPackage(PakFile, nullptr, EAssetStreamingMode::Local, *Args);

  3. Crashed while load the PAK file in StreamPackage()

  4. Error Message is "LoadPackageAsync failed to begin to load a package because the supplied package name was neither a valid long package name nor a filename of a map within a content folder: ''"

What is a problem of my code?

avatar image Muzaheed Apr 17 '16 at 02:29 AM

mfish,which engine version you were using?

avatar image hugomj_ca Apr 19 '16 at 02:23 PM

Hi Zetarus, the reason for the crash is highly likely because the pak file you are using is not cooked for Android, to do such thing just open UE4 Editor then go to File->Cook Content for Android and when is done create the pak file using the uassets located in:

YourProjectName\Saved\Cooked\AndroidXXX\

Remember if you create a pak file just using directly the uncooked content located in YourProjectName\Content it wont work on standalone builds, pak files created in that way just work when launching the game within the Editor and its intended for debugging purposes.

That should be it.

Hugo.

avatar image mfish Apr 19 '16 at 02:57 PM

This solution has been working for me since 4.6 and still works today. The assets do need to be cooked prior to packing as detailed by hugomj_ca. This works in standalone builds only due to the cooked/uncooked issue in the IDE. In my implementation I used libcurl to download the pak files from a server and then loaded them, all during runtime, with the method above.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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