Skip to content

Commit

Permalink
fix: No errors when importing empty scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
atteneder committed Oct 14, 2021
1 parent 4a4c4da commit a52131b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] -
### Fixed
- Corrected mesh bounds (calculated from accessor's min/max)
- No errors when importing empty scenes

## [4.3.2] - 2020-10-13
### Added
Expand Down
8 changes: 5 additions & 3 deletions Runtime/Scripts/GameObjectInstantiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@ uint[] nodeIndices
var go = new GameObject(name ?? "Scene");
go.transform.SetParent( parent, false);

foreach(var nodeIndex in nodeIndices) {
if (nodes[nodeIndex] != null) {
nodes[nodeIndex].transform.SetParent( go.transform, false );
if (nodeIndices != null) {
foreach(var nodeIndex in nodeIndices) {
if (nodes[nodeIndex] != null) {
nodes[nodeIndex].transform.SetParent( go.transform, false );
}
}
}

Expand Down
13 changes: 8 additions & 5 deletions Runtime/Scripts/GltfImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1588,13 +1588,16 @@ void PopulateHierarchy(uint nodeIndex, uint? parentIndex) {

var scene = gltfRoot.scenes[sceneId];
instantiator.Init();

if (scene.nodes != null) {
foreach (var nodeId in scene.nodes) {
IterateNodes(nodeId,null,CreateHierarchy);
}

foreach (var nodeId in scene.nodes) {
IterateNodes(nodeId,null,CreateHierarchy);
}

foreach (var nodeId in scene.nodes) {
IterateNodes(nodeId,null,PopulateHierarchy);
foreach (var nodeId in scene.nodes) {
IterateNodes(nodeId,null,PopulateHierarchy);
}
}

#if UNITY_ANIMATION
Expand Down

0 comments on commit a52131b

Please sign in to comment.