From 1cb4bf27ad047d5d09013bbc155be9afb5b5bff2 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 15 Sep 2020 14:23:02 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A6=8B=E3=81=A4=E3=81=8B=E3=82=89=E3=81=AA?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=20?= =?UTF-8?q?=E5=90=8C=E5=90=8D=20=E3=81=AE=20GameObject=20=E3=81=A7?= =?UTF-8?q?=E6=9C=80=E5=88=9D=E3=81=AB=E8=A6=8B=E3=81=A4=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=82=82=E3=81=AE=E3=81=AB=20fallback=20=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Format/glTF_VRMExtensions.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs b/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs index 9e0955f6b..47e10a1df 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs +++ b/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs @@ -19,13 +19,27 @@ namespace VRM public static glTF_VRM_BlendShapeBind Create(Transform root, BlendShapeBinding binding, gltfExporter exporter) { - var transform = root.transform.Find(binding.RelativePath); - if (transform == null) + if (string.IsNullOrEmpty((binding.RelativePath))) { - Debug.LogWarning($"{binding.RelativePath} not found"); + Debug.LogWarning("binding.RelativePath is null"); return null; } - var renderer = transform.GetComponent(); + var found = root.transform.Find(binding.RelativePath); + if (found == null) + { + var name = binding.RelativePath.Split('/').Last(); + found = root.GetComponentsInChildren().Where(x => x.name == name).First(); + if (found == null) + { + Debug.LogWarning($"{binding.RelativePath} not found"); + return null; + } + else + { + Debug.LogWarning($"fall back '{binding.RelativePath}' => '{found.RelativePathFrom(root)}'"); + } + } + var renderer = found.GetComponent(); if (renderer == null) { return null;