/// <summary> /// エクスポート可能か検証する /// </summary> /// <returns></returns> public IEnumerable <Validation> Validate() { if (Source == null) { yield return(Validation.Error("Require source")); yield break; } if (Source.transform.position != Vector3.zero || Source.transform.rotation != Quaternion.identity || Source.transform.localScale != Vector3.one) { EditorUtility.DisplayDialog("Error", "The Root transform should have Default translation, rotation and scale.", "ok"); yield return(Validation.Error("The Root transform should have Default translation, rotation and scale.")); } var animator = Source.GetComponent <Animator>(); if (animator == null) { yield return(Validation.Error("Require animator. ")); } else if (animator.avatar == null) { yield return(Validation.Error("Require animator.avatar. ")); } else if (!animator.avatar.isValid) { yield return(Validation.Error("Animator.avatar is not valid. ")); } else if (!animator.avatar.isHuman) { yield return(Validation.Error("Animator.avatar is not humanoid. Please change model's AnimationType to humanoid. ")); } var jaw = animator.GetBoneTransform(HumanBodyBones.Jaw); if (jaw != null) { yield return(Validation.Warning("Jaw bone is included. It may not be what you intended. Please check the humanoid avatar setting screen")); } if (DuplicateBoneNameExists()) { yield return(Validation.Error("Find duplicate Bone names. Please check model's bone names. ")); } if (string.IsNullOrEmpty(Title)) { yield return(Validation.Error("Require Title. ")); } if (string.IsNullOrEmpty(Version)) { yield return(Validation.Error("Require Version. ")); } if (string.IsNullOrEmpty(Author)) { yield return(Validation.Error("Require Author. ")); } if (ReduceBlendshape && Source.GetComponent <VRMBlendShapeProxy>() == null) { yield return(Validation.Error("ReduceBlendshapeSize needs VRMBlendShapeProxy. You need to convert to VRM once.")); } var vertexColor = Source.GetComponentsInChildren <SkinnedMeshRenderer>().Any(x => x.sharedMesh.colors.Length > 0); if (vertexColor) { yield return(Validation.Warning("This model contains vertex color")); } var renderers = Source.GetComponentsInChildren <Renderer>(); if (renderers.All(x => !x.gameObject.activeInHierarchy)) { yield return(Validation.Error("No active mesh")); } var materials = renderers.SelectMany(x => x.sharedMaterials).Distinct(); foreach (var material in materials) { if (material.shader.name == "Standard") { // standard continue; } if (MaterialExporter.UseUnlit(material.shader.name)) { // unlit continue; } if (VRMMaterialExporter.VRMExtensionShaders.Contains(material.shader.name)) { // VRM supported continue; } yield return(Validation.Warning(string.Format("unknown material '{0}' is used. this will export as `Standard` fallback", material.shader.name))); } foreach (var material in materials) { if (IsFileNameLengthTooLong(material.name)) { yield return(Validation.Error(string.Format("FileName '{0}' is too long. ", material.name))); } } var textureNameList = new List <string>(); foreach (var material in materials) { var shader = material.shader; int propertyCount = ShaderUtil.GetPropertyCount(shader); for (int i = 0; i < propertyCount; i++) { if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) { if ((material.GetTexture(ShaderUtil.GetPropertyName(shader, i)) != null)) { var textureName = material.GetTexture(ShaderUtil.GetPropertyName(shader, i)).name; if (!textureNameList.Contains(textureName)) { textureNameList.Add(textureName); } } } } } foreach (var textureName in textureNameList) { if (IsFileNameLengthTooLong(textureName)) { yield return(Validation.Error(string.Format("FileName '{0}' is too long. ", textureName))); } } var vrmMeta = Source.GetComponent <VRMMeta>(); if (vrmMeta != null && vrmMeta.Meta != null && vrmMeta.Meta.Thumbnail != null) { var thumbnailName = vrmMeta.Meta.Thumbnail.name; if (IsFileNameLengthTooLong(thumbnailName)) { yield return(Validation.Error(string.Format("FileName '{0}' is too long. ", thumbnailName))); } } var meshFilters = Source.GetComponentsInChildren <MeshFilter>(); var meshesName = meshFilters.Select(x => x.sharedMesh.name).Distinct(); foreach (var meshName in meshesName) { if (IsFileNameLengthTooLong(meshName)) { yield return(Validation.Error(string.Format("FileName '{0}' is too long. ", meshName))); } } var skinnedmeshRenderers = Source.GetComponentsInChildren <SkinnedMeshRenderer>(); var skinnedmeshesName = skinnedmeshRenderers.Select(x => x.sharedMesh.name).Distinct(); foreach (var skinnedmeshName in skinnedmeshesName) { if (IsFileNameLengthTooLong(skinnedmeshName)) { yield return(Validation.Error(string.Format("FileName '{0}' is too long. ", skinnedmeshName))); } } }
/// <summary> /// エクスポート可能か検証する /// </summary> /// <returns></returns> public IEnumerable <Validation> Validate() { if (Source == null) { yield return(Validation.Error("Require source")); yield break; } var animator = Source.GetComponent <Animator>(); if (animator == null) { yield return(Validation.Error("Require animator. ")); } else if (animator.avatar == null) { yield return(Validation.Error("Require animator.avatar. ")); } else if (!animator.avatar.isValid) { yield return(Validation.Error("Animator.avatar is not valid. ")); } else if (!animator.avatar.isHuman) { yield return(Validation.Error("Animator.avatar is not humanoid. Please change model's AnimationType to humanoid. ")); } var jaw = animator.GetBoneTransform(HumanBodyBones.Jaw); if (jaw != null) { yield return(Validation.Warning("Jaw bone is included. It may not be what you intended. Please check the humanoid avatar setting screen")); } if (DuplicateBoneNameExists()) { yield return(Validation.Error("Find duplicate Bone names. Please check model's bone names. ")); } if (string.IsNullOrEmpty(Title)) { yield return(Validation.Error("Require Title. ")); } if (string.IsNullOrEmpty(Version)) { yield return(Validation.Error("Require Version. ")); } if (string.IsNullOrEmpty(Author)) { yield return(Validation.Error("Require Author. ")); } if (ReduceBlendshape && Source.GetComponent <VRMBlendShapeProxy>() == null) { yield return(Validation.Error("ReduceBlendshapeSize is need VRMBlendShapeProxy, you need to convert to VRM once.")); } var vertexColor = Source.GetComponentsInChildren <SkinnedMeshRenderer>().Any(x => x.sharedMesh.colors.Length > 0); if (vertexColor) { yield return(Validation.Warning("This model contains vertex color")); } var renderers = Source.GetComponentsInChildren <Renderer>(); if (renderers.All(x => !x.gameObject.activeInHierarchy)) { yield return(Validation.Error("No active mesh")); } var materials = renderers.SelectMany(x => x.sharedMaterials).Distinct(); foreach (var material in materials) { if (material.shader.name == "Standard") { // standard continue; } if (MaterialExporter.UseUnlit(material.shader.name)) { // unlit continue; } if (VRMMaterialExporter.VRMExtensionShaders.Contains(material.shader.name)) { // VRM supported continue; } yield return(Validation.Warning(string.Format("unknown material '{0}' is used. this will export as `Standard` fallback", material.shader.name))); } }