From 41342c26e1104ce3b8b53d62e90cf35d1e2d1817 Mon Sep 17 00:00:00 2001 From: sh_akira Date: Fri, 12 Oct 2018 02:39:50 +0900 Subject: [PATCH 1/2] [VRMRuntimeLoader] fix obsolete import API to new API --- .../VRM.Samples/Scripts/VRMRuntimeLoader.cs | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs b/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs index 9332f72..234319d 100644 --- a/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs +++ b/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs @@ -103,8 +103,8 @@ void LoadVRMClicked() } else { - VRMImporter.LoadFromBytes(context); - OnLoaded(context.Root); + context.Load(); + OnLoaded(context); } } @@ -127,15 +127,20 @@ void LoadVRMClicked_without_meta() var bytes = File.ReadAllBytes(path); // なんらかの方法でByte列を得た + var context = new VRMImporterContext(); + + // GLB形式でJSONを取得しParseします + context.ParseGlb(bytes); + if (m_loadAsync) { // ローカルファイルシステムからロードします - VRMImporter.LoadVrmAsync(bytes, OnLoaded); + LoadAsync(context); } else { - var root=VRMImporter.LoadFromBytes(bytes); - OnLoaded(root); + context.Load(); + OnLoaded(context); } #else @@ -158,10 +163,11 @@ void LoadAsync(VRMImporterContext context) { #if true var now = Time.time; - VRMImporter.LoadVrmAsync(context, go=> { + context.LoadAsync(_ => + { var delta = Time.time - now; - Debug.LogFormat("LoadVrmAsync {0:0.0} seconds", delta); - OnLoaded(go); + Debug.LogFormat("LoadAsync {0:0.0} seconds", delta); + OnLoaded(context); }); #else // ローカルファイルシステムからロードします @@ -182,10 +188,14 @@ void LoadBVHClicked() #endif } - void OnLoaded(GameObject root) + void OnLoaded(VRMImporterContext context) { + var root = context.Root; root.transform.SetParent(transform, false); + //メッシュを表示します + context.ShowMeshes(); + // add motion var humanPoseTransfer = root.AddComponent(); if (m_target != null) @@ -199,11 +209,10 @@ void OnLoaded(GameObject root) void LoadBvh(string path) { Debug.LogFormat("ImportBvh: {0}", path); - var context = new UniHumanoid.ImporterContext - { - Path = path - }; - UniHumanoid.BvhImporter.Import(context); + var context = new UniHumanoid.BvhImporterContext(); + + context.Parse(path); + context.Load(); if (m_source != null) { From 98e431cdb8dae5265f113310b2eef22c615408fe Mon Sep 17 00:00:00 2001 From: sh_akira Date: Fri, 12 Oct 2018 02:58:39 +0900 Subject: [PATCH 2/2] [VRMRuntimeLoaderNet4] fix obsolete import API to new API --- .../Scripts/VRMRuntimeLoaderNet4.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Assets/VRM.Samples/Scripts/VRMRuntimeLoaderNet4.cs b/Assets/VRM.Samples/Scripts/VRMRuntimeLoaderNet4.cs index 7342f49..d578817 100644 --- a/Assets/VRM.Samples/Scripts/VRMRuntimeLoaderNet4.cs +++ b/Assets/VRM.Samples/Scripts/VRMRuntimeLoaderNet4.cs @@ -91,12 +91,12 @@ async void LoadVRMClicked() return; } - var context = new VRMImporterContext(path); + var context = new VRMImporterContext(); var bytes = await ReadBytesAsync(path); // GLB形式でJSONを取得しParseします - context.ParseVrm(bytes); + context.ParseGlb(bytes); // metaを取得(todo: thumbnailテクスチャのロード) var meta = context.ReadMeta(); @@ -104,11 +104,11 @@ async void LoadVRMClicked() // ParseしたJSONをシーンオブジェクトに変換していく var now = Time.time; - var go = await VRMImporter.LoadVrmAsync(context); + await context.LoadAsyncTask(); var delta = Time.time - now; Debug.LogFormat("LoadVrmAsync {0:0.0} seconds", delta); - OnLoaded(go); + OnLoaded(context); } void LoadBVHClicked() @@ -124,10 +124,14 @@ void LoadBVHClicked() #endif } - void OnLoaded(GameObject root) + void OnLoaded(VRMImporterContext context) { + var root = context.Root; root.transform.SetParent(transform, false); + //メッシュを表示します + context.ShowMeshes(); + // add motion var humanPoseTransfer = root.AddComponent(); if (m_target != null) @@ -141,11 +145,10 @@ void OnLoaded(GameObject root) void LoadBvh(string path) { Debug.LogFormat("ImportBvh: {0}", path); - var context = new UniHumanoid.ImporterContext - { - Path = path - }; - UniHumanoid.BvhImporter.Import(context); + var context = new UniHumanoid.BvhImporterContext(); + + context.Parse(path); + context.Load(); if (m_source != null) {