Merge pull request #430 from KaiserM21/dev

Fix Overwrite Material Index
This commit is contained in:
Valentin
2023-10-30 20:51:13 +01:00
committed by GitHub

View File

@@ -517,13 +517,11 @@ public class Renderer : IDisposable
if (staticMeshComp.TryGetValue(out FPackageIndex[] overrideMaterials, "OverrideMaterials"))
{
var max = model.Sections.Length - 1;
for (var j = 0; j < overrideMaterials.Length; j++)
for (var j = 0; j < overrideMaterials.Length && j < model.Sections.Length; j++)
{
if (j > max) break;
if (!model.Materials[model.Sections[j].MaterialIndex].IsUsed ||
overrideMaterials[j].Load() is not UMaterialInterface unrealMaterial) continue;
model.Materials[model.Sections[j].MaterialIndex].SwapMaterial(unrealMaterial);
var matIndex = model.Sections[j].MaterialIndex;
if (!(model.Materials[matIndex].IsUsed && overrideMaterials[matIndex].Load() is UMaterialInterface unrealMaterial)) continue;
model.Materials[matIndex].SwapMaterial(unrealMaterial);
}
}