Fix bug in package loading
This commit is contained in:
@@ -139,18 +139,16 @@ WingFetcher& WingFetcher::Asset(const FString& PackagePath)
|
||||
return SetError();
|
||||
}
|
||||
|
||||
// Check if the package exists before calling LoadObject, because
|
||||
// LoadObject logs its own errors when the package doesn't exist.
|
||||
FString PackageName = FPackageName::ObjectPathToPackageName(PackagePath);
|
||||
if (!FPackageName::DoesPackageExist(PackageName))
|
||||
UPackage* Package = LoadPackage(nullptr, *PackagePath, LOAD_NoWarn);
|
||||
if (!Package)
|
||||
{
|
||||
Errors.Printf(TEXT("ERROR: Asset '%s' does not exist.\n"), *PackagePath);
|
||||
return SetError();
|
||||
}
|
||||
SetObj(LoadObject<UObject>(nullptr, *PackagePath));
|
||||
SetObj(Package->FindAssetInPackage());
|
||||
if (!Obj)
|
||||
{
|
||||
Errors.Printf(TEXT("ERROR: Could not load asset '%s'\n"), *PackagePath);
|
||||
Errors.Printf(TEXT("ERROR: Could not find asset in package '%s'\n"), *PackagePath);
|
||||
return SetError();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user