Skip to content

Commit

Permalink
Merge pull request #689 from ousttrue/fix/empty_node_name
Browse files Browse the repository at this point in the history
FixNodeName
  • Loading branch information
ousttrue authored Jan 25, 2021
2 parents dda0ce2 + 7fa8bc0 commit d5ae902
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public virtual void ParseJson(string json, IStorage storage)
RestoreOlderVersionValues();

FixUnique();
FixNodeName();

// parepare byte buffer
//GLTF.baseDir = System.IO.Path.GetDirectoryName(Path);
Expand Down Expand Up @@ -346,6 +347,21 @@ void FixUnique()
}
}

/// <summary>
/// rename empty name to $"{index}"
/// </summary>
void FixNodeName()
{
for (var i = 0; i < GLTF.nodes.Count; ++i)
{
var node = GLTF.nodes[i];
if (string.IsNullOrWhiteSpace(node.name))
{
node.name = $"{i}";
}
}
}

void RestoreOlderVersionValues()
{
var parsed = UniJSON.JsonParser.Parse(Json);
Expand Down

0 comments on commit d5ae902

Please sign in to comment.