Another problem appear: I try to load blueprint after mounting pack pak file and fail.
My loading process can run in PIE mode, can run in packaged mode when having main pak and pack pak together. Error only happens when I launch game with main pak only and try to mount pack pak file.
It shows that the problem of texture doesn’t refresh is hidden. Now the biggest problem is, why I can’t load blueprint when pak is mounted successfully.
My loading blueprint code is
bool UPakBlueprintLibrary::SpawnActorFromBPPath(const FString& BPPath, UObject* WorldContextObject, AActor*& OutActor)
{
OutActor = nullptr;
if (!WorldContextObject)
{
UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: WorldContextObject is null"));
return false;
}
UWorld* World = WorldContextObject->GetWorld();
if (!World)
{
UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: Cannot get UWorld from WorldContextObject"));
return false;
}
// Load the Blueprint class
UClass* BPClass = LoadObject<UClass>(nullptr, *BPPath);
if (!BPClass)
{
UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: Failed to load BP class at path: %s"), *BPPath);
return false;
}
// Spawn parameters
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
AActor* NewActor = World->SpawnActor<AActor>(BPClass, FVector::ZeroVector, FRotator::ZeroRotator, SpawnParams);
if (!NewActor)
{
UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: Failed to spawn actor from BP class"));
return false;
}
OutActor = NewActor;
return true;
}