From 77f9010b065aec351f93b572ed6077f27f5d75b5 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 28 May 2021 11:54:11 +0200 Subject: [PATCH] Fix exception in Editor UI is model has invalid material slot index assigned --- .../Editors/ModelInstanceEntryEditor.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/ModelInstanceEntryEditor.cs b/Source/Editor/CustomEditors/Editors/ModelInstanceEntryEditor.cs index 6ecac91ee..f150eec88 100644 --- a/Source/Editor/CustomEditors/Editors/ModelInstanceEntryEditor.cs +++ b/Source/Editor/CustomEditors/Editors/ModelInstanceEntryEditor.cs @@ -38,8 +38,12 @@ namespace FlaxEditor.CustomEditors.Editors var model = staticModel.Model; if (model && model.IsLoaded) { - _group.Panel.HeaderText = "Entry " + model.MaterialSlots[entryIndex].Name; - _updateName = false; + var slots = model.MaterialSlots; + if (slots != null && slots.Length > entryIndex) + { + _group.Panel.HeaderText = "Entry " + slots[entryIndex].Name; + _updateName = false; + } } } else if (ParentEditor.ParentEditor.Values[0] is AnimatedModel animatedModel) @@ -47,8 +51,12 @@ namespace FlaxEditor.CustomEditors.Editors var model = animatedModel.SkinnedModel; if (model && model.IsLoaded) { - _group.Panel.HeaderText = "Entry " + model.MaterialSlots[entryIndex].Name; - _updateName = false; + var slots = model.MaterialSlots; + if (slots != null && slots.Length > entryIndex) + { + _group.Panel.HeaderText = "Entry " + slots[entryIndex].Name; + _updateName = false; + } } } }