From 5a86d036bf2299ca0f75fffebe699ffe8cf500a4 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 9 Apr 2021 12:20:26 +0900 Subject: [PATCH] conflict --- Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs | 14 +++++++++++++- Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs | 3 +-- Assets/VRM10/Runtime/Migration/MigrationVrm.cs | 10 ++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs index 3d3e6d280..0b63716f2 100644 --- a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs +++ b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs @@ -226,6 +226,18 @@ namespace UniVRM10 await LoadConstraintAsync(awaitCaller, controller); } + static ExpressionKey Key(UniGLTF.Extensions.VRMC_vrm.Expression e) + { + if (e.Preset == UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.custom) + { + return ExpressionKey.CreateCustom(e.Name); + } + else + { + return ExpressionKey.CreateFromPreset(e.Preset); + } + } + async Task LoadVrmAsync(IAwaitCaller awaitCaller, VRM10Controller controller, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm) { // meta @@ -281,7 +293,7 @@ namespace UniVRM10 var clip = ScriptableObject.CreateInstance(); clip.Preset = expression.Preset; clip.ExpressionName = expression.Name; - clip.name = expression.ExtractName(); + clip.name = Key(expression).ExtractKey; clip.IsBinary = expression.IsBinary.GetValueOrDefault(); clip.OverrideBlink = expression.OverrideBlink; clip.OverrideLookAt = expression.OverrideLookAt; diff --git a/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs b/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs index cdbab35a9..67d688e4c 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs @@ -1,8 +1,7 @@ using System; -// using System.Collections.Generic; using System.Linq; using UniGLTF; -using UniGLTF.ShaderPropExporter; +// using UniGLTF.ShaderPropExporter; using UnityEngine; using VRMShaders; diff --git a/Assets/VRM10/Runtime/Migration/MigrationVrm.cs b/Assets/VRM10/Runtime/Migration/MigrationVrm.cs index e7afc4d1f..48ef62c10 100644 --- a/Assets/VRM10/Runtime/Migration/MigrationVrm.cs +++ b/Assets/VRM10/Runtime/Migration/MigrationVrm.cs @@ -14,12 +14,17 @@ namespace UniVRM10 { var glb = UniGLTF.Glb.Parse(src); var json = glb.Json.Bytes.ParseAsJson(); + return Migrate(json, glb.Binary.Bytes); + } + + public static byte[] Migrate(JsonNode json, ArraySegment bin) + { var gltf = UniGLTF.GltfDeserializer.Deserialize(json); // attach glb bin to buffer foreach (var buffer in gltf.buffers) { - buffer.OpenStorage(new UniGLTF.SimpleStorage(glb.Binary.Bytes)); + buffer.OpenStorage(new UniGLTF.SimpleStorage(bin)); } // https://github.com/vrm-c/vrm-specification/issues/205 @@ -71,7 +76,8 @@ namespace UniVRM10 UniGLTF.GltfSerializer.Serialize(f, gltf); vrm1Json = f.GetStoreBytes(); } - return UniGLTF.Glb.Create(vrm1Json, glb.Binary.Bytes).ToBytes(); + // JSON 部分だけが改変されて、BIN はそのまま + return UniGLTF.Glb.Create(vrm1Json, bin).ToBytes(); } public static void Check(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm1)