Skip to content

Commit 5eefeb4

Browse files
committed
Fixed prefab collection loading issues in non-editor builds
1 parent c5d6d1a commit 5eefeb4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,21 @@ UPrefabricatorAsset* UPrefabricatorAssetCollection::GetPrefabAsset(const FPrefab
106106
else {
107107
float SelectionValue = Random.FRandRange(0, TotalWeight);
108108
float StartRange = 0.0f;
109+
bool bFound = false;
109110
for (const FPrefabricatorAssetCollectionItem& Item : Prefabs) {
110111
float EndRange = StartRange + Item.Weight;
111112
if (SelectionValue >= StartRange && SelectionValue < EndRange) {
112113
PrefabAssetPtr = Item.PrefabAsset;
114+
bFound = true;
113115
break;
114116
}
115117
StartRange = EndRange;
116118
}
117-
if (!PrefabAssetPtr.IsValid()) {
119+
if (!bFound) {
118120
PrefabAssetPtr = Prefabs.Last().PrefabAsset;
119121
}
120122
}
121-
if (PrefabAssetPtr.IsValid()) {
122-
return PrefabAssetPtr.LoadSynchronous();
123-
}
124-
return nullptr;
123+
return PrefabAssetPtr.LoadSynchronous();
125124
}
126125

127126
void UPrefabricatorEventListener::PostSpawn_Implementation(APrefabActor* Prefab)

0 commit comments

Comments
 (0)