Hi guys, I try to mount pak file at running time and then load the static mesh use, it works on both editor and standalone version of window.
However it will not work on android( I did package the pak file using android cooked assets)
this is the code:
bool ATangoObjectVisGameModeBase::StartStreaming()
{
if (PakPlatform.IsValid())
{
if (PakPlatform->Initialize(PlatformFile, TEXT("")))
{
FPlatformFileManager::Get().SetPlatformFile(*PakPlatform);
const FString PakFileRemotePath = AndroidDir; //FString(TEXT("D:/OutpakEditor.pak"));
FPakFile PakFile(PlatformFile, *PakFileRemotePath, false);
if (PakFile.IsValid())
{
// We have to mount the file into the engine content dir, if not you will not be able to load it async!
PakFile.SetMountPoint(*FPaths::EngineContentDir());
if (PakPlatform->Mount(*PakFileRemotePath, 0, *FPaths::EngineContentDir())) // This is the byte order
{
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Red, FString::Printf(TEXT("EngineContentDir '%s'"), *FPaths::EngineContentDir()));
// The assets we will stream from the Pak file
TSet<FString> PakContent;
PakFile.FindFilesAtPath(PakContent, *PakFile.GetMountPoint(), true, false, true);
int tempCount = 0;
for (TSet<FString>::TConstIterator SetIt(PakContent); SetIt; ++SetIt)
{
FString AssetName = *SetIt;
// You might load other such as .umaps too I guess :D
if (AssetName.EndsWith(FPackageName::GetAssetPackageExtension()))
{
// This is where we change the path to be an engine path (as stated earlier)
FString AssetShortName = FPackageName::GetShortName(AssetName);
AssetShortName.RemoveFromEnd(FPackageName::GetAssetPackageExtension());
AssetName = TEXT("/Engine/") + AssetShortName + TEXT(".") + AssetShortName;
TargetAssets.Add(AssetName);
//take assetname check if texture,model, and apply accordingly
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Red, FString::Printf(TEXT("AssetName %d : '%s'"), tempCount,*AssetName));
tempCount++;
}
}
FStreamableManager& Streamable = USolusDataSingleton::Get().Streamable;
//Streamable.RequestAsyncLoad(TargetAssets, FStreamableDelegate::CreateUObject(this, &ATangoObjectVisGameModeBase::OnStreamingCompleteDelegate));
//FPaths::EngineContentDir() + "Arrow.uasset"
Object = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, *TargetAssets[0].ToString()));
if (Object != nullptr)
{
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Red, TEXT("object 22"));
}
Object = Cast<UStaticMesh>(Streamable.SynchronousLoad(TargetAssets[0]));
if (Object != nullptr)
{
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Red, TEXT("object 1"));
}
}
}
}
}
return false;
}
this is the output:
2017.02.12-15.34.00 [Project Tango Tablet Development Kit-15207] 00008.002: LogProfilerService: Subscribe Session: 7670430749ED18BCC19075B7CAA808B1, Instance: 0000433E34020F0C002102520EE1EEFA
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.715: LogTemp: open/create the file Success
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.720: LogBlueprintUserMessages: [ARGameMode_C_0] Success
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.721: LogModuleManager: ModuleManager: Module 'HTTPChunkInstaller' not found - its StaticallyLinkedModuleInitializers function is null.
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.726: LogModuleManager: ModuleManager: Module 'HTTPChunkInstaller' not found - its StaticallyLinkedModuleInitializers function is null.
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.730: LogModuleManager: ModuleManager: Module 'HTTPChunkInstaller' not found - its StaticallyLinkedModuleInitializers function is null.
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.744: LogLinker: Can't find file '/Engine/Content/Arrow'
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.745: LogUObjectGlobals: Failed to load '/Engine/Content/Arrow': Can't find file '/Engine/Content/Arrow'
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.748: LogLinker: Can't find file '/Engine/Content/Arrow'
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.748: LogUObjectGlobals: Failed to load '/Engine/Content/Arrow': Can't find file '/Engine/Content/Arrow'
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.750: LogUObjectGlobals: Failed to find object 'Object /Engine/Content/Arrow.Arrow'
2017.02.12-15.34.05 [Project Tango Tablet Development Kit-15207] 00013.751: LogStreamableManager: Failed attempt to load /Engine/Content/Arrow.Arrow
I also did try using this:
FCoreDelegates::OnMountPak.Execute(*AndroidDir, 0, nullptr)
but nth work : /
not sure why unreal can’t find the file : / on android… please help guys