diff --git a/ChangeLog.md b/ChangeLog.md index b2bd50e8..53fd5ead 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] - +### Fixed +- Loading glTFs with nothing but accessors/bufferViews/buffers (#422) +- Loading glTFs with invalid embed buffers (#422) + ## [4.8.2] - 2022-06-15 ### Changed - Load textures/images, even when not referenced by material (#418) diff --git a/Runtime/Scripts/GltfImport.cs b/Runtime/Scripts/GltfImport.cs index ec6dcc4d..38c5c1e2 100644 --- a/Runtime/Scripts/GltfImport.cs +++ b/Runtime/Scripts/GltfImport.cs @@ -717,7 +717,7 @@ async Task ParseJsonAndLoadBuffers( string json, Uri baseUri ) { buffer.uri, true // usually there's just one buffer and it's time-critical ); - buffers[i] = decodedBuffer.Item1; + buffers[i] = decodedBuffer?.Item1; if(buffers[i]==null) { logger?.Error(LogCode.EmbedBufferLoadFailed); return false; @@ -2244,17 +2244,19 @@ async Task LoadAccessorData( Root gltf ) { } } - foreach (var node in gltf.nodes) { - var attr = node.extensions?.EXT_mesh_gpu_instancing?.attributes; - if ( attr != null) { - if (attr.TRANSLATION >= 0) { - SetAccessorUsage(attr.TRANSLATION,AccessorUsage.Translation | AccessorUsage.RequiredForInstantiation); - } - if (attr.ROTATION >= 0) { - SetAccessorUsage(attr.ROTATION,AccessorUsage.Rotation | AccessorUsage.RequiredForInstantiation); - } - if (attr.SCALE >= 0) { - SetAccessorUsage(attr.SCALE,AccessorUsage.Scale | AccessorUsage.RequiredForInstantiation); + if (gltf.nodes != null) { + foreach (var node in gltf.nodes) { + var attr = node.extensions?.EXT_mesh_gpu_instancing?.attributes; + if ( attr != null) { + if (attr.TRANSLATION >= 0) { + SetAccessorUsage(attr.TRANSLATION,AccessorUsage.Translation | AccessorUsage.RequiredForInstantiation); + } + if (attr.ROTATION >= 0) { + SetAccessorUsage(attr.ROTATION,AccessorUsage.Rotation | AccessorUsage.RequiredForInstantiation); + } + if (attr.SCALE >= 0) { + SetAccessorUsage(attr.SCALE,AccessorUsage.Scale | AccessorUsage.RequiredForInstantiation); + } } } }