From ca3d39df280aadede4c4008d4ae3eaa75f063afd Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 8 Mar 2021 19:56:23 +0900 Subject: [PATCH] fix --- .../Runtime/UniGLTF/IO/MaterialLoader/PBRMaterialItem.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialLoader/PBRMaterialItem.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialLoader/PBRMaterialItem.cs index 7503a6a18..8d53c14c0 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialLoader/PBRMaterialItem.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialLoader/PBRMaterialItem.cs @@ -71,13 +71,12 @@ namespace UniGLTF { getTexture = (_x, _y, _z) => Task.FromResult(null); } - var src = gltf.materials[i]; - - var material = MaterialFactory.CreateMaterial(i, src, ShaderName); // PBR material - if (src != null) + var material = MaterialFactory.CreateMaterial(i, null, ShaderName); + if (i >= 0 && i < gltf.materials.Count) { + var src = gltf.materials[i]; if (src.pbrMetallicRoughness != null) { if (src.pbrMetallicRoughness.baseColorFactor != null && src.pbrMetallicRoughness.baseColorFactor.Length == 4)