diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExporterMenu.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExporterMenu.cs index a172a48f9..eab7a87a1 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExporterMenu.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExporterMenu.cs @@ -25,6 +25,18 @@ namespace VRM wiz.OnWizardUpdate(); } + void OnEnable() + { + // Debug.Log("OnEnable"); + EditorApplication.hierarchyWindowChanged += OnWizardUpdate; + } + + void OnDisable() + { + // Debug.Log("OnDisable"); + EditorApplication.hierarchyWindowChanged -= OnWizardUpdate; + } + void OnWizardCreate() { // save dialog diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs index cf3ec51c0..810569848 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMExportSettings.cs @@ -83,6 +83,11 @@ namespace VRM { yield return "ReduceBlendshapeSize is need VRMBlendShapeProxy, you need to convert to VRM once."; } + + if(Source.GetComponentsInChildren().All(x => !x.gameObject.activeInHierarchy)) + { + yield return "No active mesh"; + } } public void InitializeFrom(GameObject go) diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs b/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs index da96c1ca3..b708500f2 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs +++ b/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs @@ -19,8 +19,22 @@ namespace VRM { var transform = UniGLTF.UnityExtensions.GetFromPath(root.transform, binding.RelativePath); var renderer = transform.GetComponent(); + if (renderer == null) + { + return null; + } + + if(!renderer.gameObject.activeInHierarchy) + { + return null; + } + var mesh = renderer.sharedMesh; var meshIndex = meshes.IndexOf(mesh); + if (meshIndex == -1) + { + return null; + } return new glTF_VRM_BlendShapeBind { @@ -36,7 +50,16 @@ namespace VRM var list = new List(); if (clip.Values != null) { - list.AddRange(clip.Values.Select(y => Create(transform, meshes.ToList(), y))); + foreach (var value in clip.Values) + { + var bind = Create(transform, meshes, value); + if (bind == null) + { + // Debug.LogFormat("{0}: skip blendshapebind", clip.name); + continue; + } + list.Add(bind); + } } var materialList = new List();