Updated UniJSON-1.1.2

This commit is contained in:
ousttrue
2018-12-26 03:21:24 +09:00
parent 2ba4b71577
commit 36522dee4d
3 changed files with 16 additions and 16 deletions

View File

@@ -45,7 +45,7 @@ namespace VRM
AssetDatabase.Refresh();
}
static string GetTitle(JsonNode node)
static string GetTitle(ListTreeNode<JsonValue> node)
{
try
{
@@ -61,7 +61,7 @@ namespace VRM
return "";
}
static void TraverseItem(JsonNode node, JsonFormatter f, UnityPath dir)
static void TraverseItem(ListTreeNode<JsonValue> node, JsonFormatter f, UnityPath dir)
{
var title = GetTitle(node);
if (string.IsNullOrEmpty(title))
@@ -82,7 +82,7 @@ namespace VRM
var subFormatter = new JsonFormatter(4);
subFormatter.BeginMap();
foreach (var _kv in node.ObjectItemsRaw)
foreach (var _kv in node.ObjectItems())
{
subFormatter.Key(_kv.Key.GetUtf8String());
Traverse(_kv.Value, subFormatter, dir);
@@ -96,12 +96,12 @@ namespace VRM
}
}
static void Traverse(JsonNode node, JsonFormatter f, UnityPath dir)
static void Traverse(ListTreeNode<JsonValue> node, JsonFormatter f, UnityPath dir)
{
if (node.IsArray())
{
f.BeginList();
foreach (var x in node.ArrayItemsRaw)
foreach (var x in node.ArrayItems())
{
TraverseItem(x, f, dir);
}
@@ -110,7 +110,7 @@ namespace VRM
else if (node.IsMap())
{
f.BeginMap();
foreach (var kv in node.ObjectItemsRaw)
foreach (var kv in node.ObjectItems())
{
f.Key(kv.Key.GetUtf8String());
TraverseItem(kv.Value, f, dir);
@@ -123,7 +123,7 @@ namespace VRM
}
}
static UnityPath SplitAndWriteJson(JsonNode parsed, UnityPath dir)
static UnityPath SplitAndWriteJson(ListTreeNode<JsonValue> parsed, UnityPath dir)
{
var f = new JsonFormatter(4);
Traverse(parsed, f, dir);

View File

@@ -94,25 +94,25 @@ namespace VRM
static Utf8String s_tagMap = Utf8String.From("tagMap");
static Utf8String s_textureProperties = Utf8String.From("textureProperties");
public static List<glTF_VRM_Material> Parse(JsonNode json)
public static List<glTF_VRM_Material> Parse(ListTreeNode<JsonValue> json)
{
var materials = json.DeserializeList<glTF_VRM_Material>();
var jsonItems = json.ArrayItemsRaw.ToArray();
var jsonItems = json.ArrayItems().ToArray();
for (int i = 0; i < materials.Count; ++i)
{
materials[i].floatProperties =
jsonItems[i][s_floatProperties].ObjectItems.ToDictionary(x => x.Key.ToString(), x => x.Value.GetSingle());
jsonItems[i][s_floatProperties].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetSingle());
materials[i].vectorProperties =
jsonItems[i][s_vectorProperties].ObjectItems.ToDictionary(x => x.Key.ToString(), x =>
jsonItems[i][s_vectorProperties].ObjectItems().ToDictionary(x => x.Key.GetString(), x =>
{
return x.Value.ArrayItems.Select(y => y.GetSingle()).ToArray();
return x.Value.ArrayItems().Select(y => y.GetSingle()).ToArray();
});
materials[i].keywordMap =
jsonItems[i][s_keywordMap].ObjectItems.ToDictionary(x => x.Key.ToString(), x => x.Value.GetBoolean());
jsonItems[i][s_keywordMap].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetBoolean());
materials[i].tagMap =
jsonItems[i][s_tagMap].ObjectItems.ToDictionary(x => x.Key.ToString(), x => x.Value.GetString());
jsonItems[i][s_tagMap].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetString());
materials[i].textureProperties =
jsonItems[i][s_textureProperties].ObjectItems.ToDictionary(x => x.Key.ToString(), x => x.Value.GetInt32());
jsonItems[i][s_textureProperties].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetInt32());
}
return materials;
}

Submodule UniGLTF updated: b1081eecf8...e7618ebfb1