From a4758d1b4dc735e03780a92f5c722613c6a90b83 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 26 Feb 2024 16:11:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?auto=20=E3=81=A7=20headless=20=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=99=E3=82=8B=E5=BF=85=E8=A6=81=E3=81=8C?= =?UTF-8?q?=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AE?= =?UTF-8?q?=20fallback=20=E3=81=AF=20both=20=E3=81=AE=E6=8C=99=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/VRM10Object/VRM10ObjectFirstPerson.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs b/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs index 120ca4387..6ac7f1b83 100644 --- a/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs +++ b/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs @@ -93,13 +93,13 @@ namespace UniVRM10 { if (x.GetRenderer(go.transform) is SkinnedMeshRenderer smr) { - // オリジナルのモデルを3人称用にする - smr.gameObject.layer = layer.ThirdPersonOnly; - // 頭を取り除いた複製モデルを作成し、1人称用にする var headless = await CreateHeadlessMeshAsync(smr, firstPersonBone, awaitCaller); if (headless != null) { + // オリジナルのモデルを3人称用にする + smr.gameObject.layer = layer.ThirdPersonOnly; + headless.gameObject.layer = layer.FirstPersonOnly; headless.transform.SetParent(smr.transform, false); if (runtime != null) @@ -107,6 +107,10 @@ namespace UniVRM10 runtime.AddRenderer(headless); } } + else + { + // ヘッドレスを作成しなかった場合は何もしない => both と同じ + } } else if (x.GetRenderer(go.transform) is MeshRenderer mr) { From a552230f4cbaa371796df7f08474f64fe0516d73 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 26 Feb 2024 16:12:06 +0900 Subject: [PATCH 2/3] =?UTF-8?q?headless=20mesh=20=E3=82=92=20destroy=20?= =?UTF-8?q?=E5=AF=BE=E8=B1=A1=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs | 5 +++++ .../Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs b/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs index 99cfaf86b..73c3e7a33 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs @@ -221,6 +221,11 @@ namespace UniGLTF Destroy(oldResource); } + public void AddResource(T resource) where T : UnityEngine.Object + { + _resources.Add((SubAssetKey.Create(resource), resource)); + } + void OnDestroy() { foreach (var (_, obj) in _resources) diff --git a/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs b/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs index 6ac7f1b83..812264422 100644 --- a/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs +++ b/Assets/VRM10/Runtime/Components/VRM10Object/VRM10ObjectFirstPerson.cs @@ -104,6 +104,7 @@ namespace UniVRM10 headless.transform.SetParent(smr.transform, false); if (runtime != null) { + runtime.AddResource(headless.sharedMesh); runtime.AddRenderer(headless); } } From e945e4bf272116e8c99075933c695ad6498b367c Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 26 Feb 2024 16:12:40 +0900 Subject: [PATCH 3/3] =?UTF-8?q?sample=20=E3=81=AE=20ShowMeshes=20=E3=81=AE?= =?UTF-8?q?=E5=91=BC=E3=81=B3=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10FirstPersonSample/VRM10RuntimeLoader.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs index 3a0feb381..f5b9328fc 100644 --- a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs +++ b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs @@ -86,11 +86,13 @@ namespace UniVRM10.FirstPersonSample async Task LoadAsync(string path, VRMShaders.IAwaitCaller awaitCaller) { - var instance = await Vrm10.LoadPathAsync(path, awaitCaller: awaitCaller); + var instance = await Vrm10.LoadPathAsync(path, awaitCaller: awaitCaller, showMeshes: false); // VR用 FirstPerson 設定 await instance.Vrm.FirstPerson.SetupAsync(instance.gameObject, awaitCaller); + instance.GetComponent().ShowMeshes(); + return instance; }