From f86dd4edfe669f7f2bf19094a6d3d6ba1642ee19 Mon Sep 17 00:00:00 2001 From: neon-izm Date: Sun, 16 Feb 2020 22:37:27 +0900 Subject: [PATCH] add bone names duplicate check. --- .../Scripts/Format/VRMExportSettings.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs index 61bccd9aad..cf3ec51c0d 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs @@ -60,7 +60,12 @@ public IEnumerable CanExport() { yield return "Animator.avatar is not humanoid. Please change model's AnimationType to humanoid. "; } - + + if (DuplicateBoneNameExists()) + { + yield return "Find duplicate Bone names. Please check model's bone names. "; + } + if (string.IsNullOrEmpty(Title)) { yield return "Require Title. "; @@ -402,6 +407,18 @@ void Export(string path, List destroy) AssetDatabase.ImportAsset(path.ToUnityRelativePath()); } } + + //ここで重複ボーン名のチェックをする + bool DuplicateBoneNameExists() + { + var bones = Source.transform.Traverse().ToArray(); + var duplicates = bones + .GroupBy(p => p.name) + .Where(g => g.Count() > 1) + .Select(g => g.Key); + + return (duplicates.Any()); + } #endif } } \ No newline at end of file