It depends on whether you require references between assets to work. If you create a DLC .pak with the root /TestDLC/ then you will have to make sure that Unreal accesses all files with that root. If you only have Texture2D assets, that don’t reference anything, then you can register any root path you like.
You are a gentleman and as scholar.
Been scratching my head for days trying to getting BP related assets to populate the registry on runtime.
Any normal assets drop into the asset registry just fine once mounting and scanning but bp ones dont work for some reason
Get all Actors from mounted .pak - Community & Industry Discussion - Epic Developer Community Forums
hey, how can i mount a pak that is in another directory? i need a way to load in paks from the steam workshop and also i need to clarify on how to register the new assets…
@BlueMountainsIO did a plugin to mount pakfiles. Yes 20Bucks. Do it yourself and you will spend multiple weeks on doing it.
Note: I did not try the plugin and I did not have a deeper look at it.
I found a solution that can work for some without code but through the Unreal Engine editor. The key to making it work is to make another Unreal project with the same name as the Original Project in which we want to put our Assets. This Second Project is the one that will be packaged with the Asset that you want to add to the Original Project. Then, in the Original Project, you need to include the package of the Second Project.
Anyway, I am looking for a solution independent of the Second Project name. I have tried to use the code proposed by @Rumbleball, but I couldn’t make it work.
After mounting the package, I tried to use this function.
GetAssetsInDirectory(const TSubclassOf<UObject> assetClass, const FString path, const bool bRecursive, TArray<UObject*>& assets)
but I don’t know what arguments to pass. I also tried to use these functions:
StaticLoadObject() and LoadSynchronous()
to load the Assets, but they return NULL.
Has anyone found a solution?
I am currently studying how to loads assets from .pak that packed by unrealpack.exe , and I have already gained some results.There are relatively few materials, if necessary, you can refer to my plan.
i have load and create a UUserWidget.
There are a few points to note.
I currently only implement creating a component and displaying it.
1.const auto& mountPoint = pPakFile->PakGetMountPoint();
FPackageName::RegisterMountPoint(“/DLG/”, pakContentPath);
i register this pack like this when PakFile is loaded. then we can find the asset at “/DLG/PakTest.PakTest_C”
- when we want to create the asset,we should use the code ,i have tryed to use function “loadobject” loadclass,and all failed.
FStringClassReference clsRef = sAssetFile;
//AMyActor is my own c++ implemented actor that inherited from AActor
UObject* pObject = clsRef.TryLoad();
or
FStringClassReference MyClassRef(sAsset);
return MyClassRef.TryLoadClass<T>();
- Assets are best to be independent or the directory is positive or not, otherwise an error may be reported that the dependent package does not exist
4.The packaged file that named .pak must be cooked
5.UE working mode is developer
class CxPakLoader
{
public:
CxPakLoader() {}
~CxPakLoader() {}
bool Init(FString const& sPakPath)
{
pNewPakPlatForm = new FPakPlatformFile();
pPlatformFile = &FPlatformFileManager::Get().GetPlatformFile();
if (!pNewPakPlatForm->Initialize(pPlatformFile, TEXT("")))
return false;
// Not sure about this, see: https://answers.unrealengine.com/questions/574388/how-to-mount-a-pak-file-at-game-content-directory.html
pNewPakPlatForm->InitializeNewAsyncIO();
// Now give the new PlatformFile to the engine.
FPlatformFileManager::Get().SetPlatformFile(*pNewPakPlatForm);
pPakFile = new FPakFile(pPlatformFile, *sPakPath, false);
const auto& mountPoint = pPakFile->PakGetMountPoint();
pNewPakPlatForm->Mount(*sPakPath, 4, *mountPoint);
FString pakContentPath = mountPoint;
FPackageName::RegisterMountPoint("/DLG/", pakContentPath);
//TArray<FString> AssetList;
//pPakFile->FindPrunedFilesAtPath(AssetList, *pPakFile->GetMountPoint(), true, false, true);
return true;
}
//"/DLG/PakTest.PakTest_C"
UObject* FindObject(FString const& sAssetFile)
{
FStringClassReference clsRef = sAssetFile;
//AMyActor is my own c++ implemented actor that inherited from AActor
UObject* pObject = clsRef.TryLoad();
return pObject;
}
template <class T>
TSubclassOf<T> TryLoadClass(FString const& sAsset) {
FStringClassReference MyClassRef(sAsset);
return MyClassRef.TryLoadClass<T>();
}
void UnInit()
{
}
private:
FPakFile* pPakFile = NULL;
IPlatformFile* pPlatformFile = NULL;
FPakPlatformFile* pNewPakPlatForm = NULL;
};
//UClass* BP_PakTestClass = LoadClass<AActor>(nullptr, TEXT("Blueprint'/Game/DLC/BP_PakTest1.BP_PakTest1_C'"));
//if (BP_PakTestClass) GetWorld()->SpawnActor<AActor>(BP_PakTestClass, FVector::ZeroVector, FRotator::ZeroRotator);
bool UCxActor::LoadPak(const FString& PakPath)
{
CxPakLoader xPakLoader;
xPakLoader.Init(PakPath);
TSubclassOf<UUserWidget> pSubClass = xPakLoader.TryLoadClass<UUserWidget>("/DLG/PakTest.PakTest_C");
if (pSubClass) {
UUserWidget* TestWidget = UWidgetBlueprintLibrary::Create(GetWorld(), pSubClass, NULL);
if (TestWidget)
TestWidget->AddToViewport();
OutputDebugString(L"------------xPakLoader.FindObject-------Success---------\r\n");
return true;
}
else {
OutputDebugString(L"------------xPakLoader.FindObject-------Failed---------\r\n");
return true;
}
return false;
}
Hi… Speaking of modding. Is it at all possible to extract assets like: BP-Anims-Levels++ from a .pak file that is cooked with UseSeperateBulkDataFiles=True and s.EventDrivenLoaderEnabled=True ?
There is a game that we are fully allowed to mod, but it’s not possible to access the Level, BP and more. Even if AllowCookedAssets is enabled these asset files are giving the: This asset is compiled and can’t be edited.
So even if i want to make a custom map, the needed BP’s and stuff can be used.
Would the developers need to make a build with these build options turned off for these to work, or is the best and maybe only way to create a modkit/SDK? Since they can’t share marketplace assets a SDK can’t contain plugins or assets they haven’t made them selfs. But i guess that can be solved by modders unpacking a developer build anyway to access it…
What settings might need to be disabled for the game to be unpacked without assets not being editable? Now they come as ubulk, uexp, uasset and .pak files are .utoc .uexp and .upak