From 933466169f3c9b2f3bef4a77591a7e4181f0e13e Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 27 Jun 2022 19:20:40 +0900 Subject: [PATCH] VRMExportSettings.KeepAnimation --- .../UniGLTF/Editor/Animation/EditorAnimationExporter.cs | 2 +- Assets/VRM/Editor/Format/VRMEditorExporter.cs | 4 +++- Assets/VRM/Editor/Format/VRMExportOptions.cs | 4 ++++ Assets/VRM/Editor/Format/VRMExportSettings.cs | 8 +++++++- Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs | 1 + Assets/VRM/Editor/Format/VRMExporterWizard.cs | 2 +- Assets/VRM/Runtime/IO/VRMExporter.cs | 3 ++- 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Assets/UniGLTF/Editor/Animation/EditorAnimationExporter.cs b/Assets/UniGLTF/Editor/Animation/EditorAnimationExporter.cs index cbf8c3404..1e482b4ef 100644 --- a/Assets/UniGLTF/Editor/Animation/EditorAnimationExporter.cs +++ b/Assets/UniGLTF/Editor/Animation/EditorAnimationExporter.cs @@ -19,7 +19,7 @@ namespace UniGLTF { clips = AnimationExporter.GetAnimationClips(animator); } - else if (animation != null) + if (animation != null) { clips = AnimationExporter.GetAnimationClips(animation); } diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs index 4003ba880..929cc1af3 100644 --- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -223,7 +223,9 @@ namespace VRM // 出力 var sw = System.Diagnostics.Stopwatch.StartNew(); var data = new UniGLTF.ExportingGltfData(); - using (var exporter = new VRMExporter(data, settings.MeshExportSettings)) + var gltfExportSettings = settings.GltfExportSettings; + using (var exporter = new VRMExporter(data, gltfExportSettings, + settings.KeepAnimation ? new EditorAnimationExporter() : null)) { exporter.Prepare(target); exporter.Export(new EditorTextureSerializer()); diff --git a/Assets/VRM/Editor/Format/VRMExportOptions.cs b/Assets/VRM/Editor/Format/VRMExportOptions.cs index 66d6b411a..1b23da7bc 100644 --- a/Assets/VRM/Editor/Format/VRMExportOptions.cs +++ b/Assets/VRM/Editor/Format/VRMExportOptions.cs @@ -47,5 +47,9 @@ namespace VRM [LangMsg(Languages.ja, "頂点カラーの自動削除をしない。")] [LangMsg(Languages.en, "Do not automatically delete vertex colors.")] KEEP_VERTEX_COLOR, + + [LangMsg(Languages.ja, "glTF Animationをエクスポートする。")] + [LangMsg(Languages.en, "export glTF animation.")] + EXPORT_GLTF_ANIMATION, } } diff --git a/Assets/VRM/Editor/Format/VRMExportSettings.cs b/Assets/VRM/Editor/Format/VRMExportSettings.cs index e4922baea..f73bab40a 100644 --- a/Assets/VRM/Editor/Format/VRMExportSettings.cs +++ b/Assets/VRM/Editor/Format/VRMExportSettings.cs @@ -55,7 +55,13 @@ namespace VRM [Tooltip("Keep vertex color attribute")] public bool KeepVertexColor = false; - public GltfExportSettings MeshExportSettings => new GltfExportSettings + /// + /// Export時にAnimationを落とさない。特別な用途で使えるように敢えて残す設定 + /// + [Tooltip("Keep animation")] + public bool KeepAnimation = false; + + public GltfExportSettings GltfExportSettings => new GltfExportSettings { UseSparseAccessorForMorphTarget = UseSparseAccessor, ExportOnlyBlendShapePosition = OnlyBlendshapePosition, diff --git a/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs index e411fe97c..9c8901ab3 100644 --- a/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs +++ b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs @@ -54,6 +54,7 @@ namespace VRM m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.ReduceBlendshapeClip)), VRMExportOptions.BLENDSHAPE_EXCLUDE_UNKNOWN)); m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.DivideVertexBuffer)), VRMExportOptions.DIVIDE_VERTEX_BUFFER)); m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.KeepVertexColor)), VRMExportOptions.KEEP_VERTEX_COLOR)); + m_checkbox_list.Add(new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.KeepAnimation)), VRMExportOptions.EXPORT_GLTF_ANIMATION)); } diff --git a/Assets/VRM/Editor/Format/VRMExporterWizard.cs b/Assets/VRM/Editor/Format/VRMExporterWizard.cs index be621b52f..ba50e49e1 100644 --- a/Assets/VRM/Editor/Format/VRMExporterWizard.cs +++ b/Assets/VRM/Editor/Format/VRMExporterWizard.cs @@ -167,7 +167,7 @@ namespace VRM protected override void OnLayout() { - m_meshes.SetRoot(State.ExportRoot, m_settings.MeshExportSettings, new VRMBlendShapeExportFilter(State.ExportRoot, m_settings)); + m_meshes.SetRoot(State.ExportRoot, m_settings.GltfExportSettings, new VRMBlendShapeExportFilter(State.ExportRoot, m_settings)); } static bool s_foldT = true; diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs index 47178ed03..77219d00b 100644 --- a/Assets/VRM/Runtime/IO/VRMExporter.cs +++ b/Assets/VRM/Runtime/IO/VRMExporter.cs @@ -25,7 +25,8 @@ namespace VRM public readonly VRM.glTF_VRM_extensions VRM = new glTF_VRM_extensions(); - public VRMExporter(ExportingGltfData data, GltfExportSettings exportSettings) : base(data, exportSettings) + public VRMExporter(ExportingGltfData data, GltfExportSettings exportSettings, IAnimationExporter animationExporter = null) : base( + data, exportSettings, animationExporter: animationExporter) { if (exportSettings == null || exportSettings.InverseAxis != Vrm0xSpecificationInverseAxis) {