diff --git a/Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs b/Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs index f8db7a1b0..8e2cf2436 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs @@ -25,29 +25,36 @@ namespace UniGLTF private static void ExportFromMenu() { var go = Selection.activeObject as GameObject; - var path = EditorUtility.SaveFilePanel( - "Save glb", - "", - go.name + ".glb", - "glb"); - if (string.IsNullOrEmpty(path)) - { - return; - } - var gltf = new glTF(); - using (var exporter = new gltfExporter(gltf)) + if (go.transform.position == Vector3.zero && + go.transform.rotation == Quaternion.identity && + go.transform.localScale == Vector3.one) { - exporter.Prepare(go); - exporter.Export(); - } - var bytes = gltf.ToGlbBytes(); - File.WriteAllBytes(path, bytes); + var path = EditorUtility.SaveFilePanel( + "Save glb", "", go.name + ".glb", "glb"); + if (string.IsNullOrEmpty(path)) + { + return; + } - if (path.StartsWithUnityAssetPath()) + var gltf = new glTF(); + using (var exporter = new gltfExporter(gltf)) + { + exporter.Prepare(go); + exporter.Export(); + } + var bytes = gltf.ToGlbBytes(); + File.WriteAllBytes(path, bytes); + + if (path.StartsWithUnityAssetPath()) + { + AssetDatabase.ImportAsset(path.ToUnityRelativePath()); + AssetDatabase.Refresh(); + } + } + else { - AssetDatabase.ImportAsset(path.ToUnityRelativePath()); - AssetDatabase.Refresh(); + EditorUtility.DisplayDialog("Error", "Root's Position, Rotation and Scale need to be Default values.", "ok"); } } #endif diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs index 7fcab98a8..31b0af119 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs @@ -152,6 +152,13 @@ namespace VRM yield break; } + if (Source.transform.position != Vector3.zero || + Source.transform.rotation != Quaternion.identity || + Source.transform.localScale != Vector3.one) + { + yield return Validation.Error("Root's Position, Rotation and Scale need to be Default values."); + } + var animator = Source.GetComponent(); if (animator == null) {