Merge pull request #1489 from ousttrue/fix10/fix_migration_meta_firstpersonboneoffset

[1.0] Migrationのエッジケースを修正
This commit is contained in:
ousttrue
2022-02-03 20:24:07 +09:00
committed by GitHub
4 changed files with 18 additions and 4 deletions

View File

@@ -52,7 +52,7 @@ namespace UniJSON
return kv.Value;
}
}
throw new KeyNotFoundException();
throw new KeyNotFoundException(key.ToString());
}
public static bool ContainsKey(this JsonNode self, Utf8String key)

View File

@@ -21,5 +21,14 @@ namespace UniVRM10
vrm0["z"].GetSingle(),
};
}
public static float[] Migrate(JsonNode parent, string key)
{
if (!parent.ContainsKey(key))
{
return new float[] { 0, 0, 0 };
}
return Migrate(parent[key]);
}
}
}

View File

@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
using UniGLTF.Extensions.VRMC_vrm;
using UniJSON;
using UnityEngine;
namespace UniVRM10
{
@@ -39,14 +41,15 @@ namespace UniVRM10
{
// VRM1
// firstPerson に同居していた LookAt は独立します
var lookAt = new LookAt
LookAt lookAt = default;
lookAt = new LookAt
{
RangeMapHorizontalInner = MigrateLookAtRangeMap(vrm0["lookAtHorizontalInner"]),
RangeMapHorizontalOuter = MigrateLookAtRangeMap(vrm0["lookAtHorizontalOuter"]),
RangeMapVerticalDown = MigrateLookAtRangeMap(vrm0["lookAtVerticalDown"]),
RangeMapVerticalUp = MigrateLookAtRangeMap(vrm0["lookAtVerticalUp"]),
Type = MigrateLookAtType(vrm0["lookAtTypeName"]),
OffsetFromHeadBone = MigrateVector3.Migrate(vrm0["firstPersonBoneOffset"]),
OffsetFromHeadBone = MigrateVector3.Migrate(vrm0, "firstPersonBoneOffset"),
};
var firstPerson = new FirstPerson

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using UniJSON;
using UnityEngine;
namespace UniVRM10
{
@@ -152,7 +153,8 @@ namespace UniVRM10
break;
default:
throw new NotImplementedException(key);
Debug.LogWarning($"[meta migration] unknown key: {key}");
break;
} // switch
} // foreach