From 28f5529d5ca79bcf81f463e79b73aef609fbd8ca Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 26 Aug 2020 13:22:30 +0900 Subject: [PATCH] VRMExportSettingsEditor.Options --- Assets/VRM/UniVRM/Editor/EditorLanguages.cs | 1 - .../Editor/Format/VRMExportSettingsEditor.cs | 88 +++++++++++++------ 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/Assets/VRM/UniVRM/Editor/EditorLanguages.cs b/Assets/VRM/UniVRM/Editor/EditorLanguages.cs index 7b496cfc5..14416d7ce 100644 --- a/Assets/VRM/UniVRM/Editor/EditorLanguages.cs +++ b/Assets/VRM/UniVRM/Editor/EditorLanguages.cs @@ -32,7 +32,6 @@ namespace VRM.M17N [LangMsg(Languages.en, "Please set up a ExportRoot for model export")] ROOT_EXISTS, - [LangMsg(Languages.ja, "ExportRootに親はオブジェクトは持てません")] [LangMsg(Languages.en, "ExportRoot must be topmost parent")] NO_PARENT, diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs index 1a4707f08..5b05edae9 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs +++ b/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs @@ -1,6 +1,8 @@ +using System; using UnityEditor; using UnityEngine; +using VRM.M17N; namespace VRM { @@ -10,18 +12,26 @@ namespace VRM class CheckBoxProp { public SerializedProperty Property; - public string Description; + public Func Description; - public CheckBoxProp(SerializedProperty property, string desc) + public CheckBoxProp(SerializedProperty property, Func desc) { Property = property; Description = desc; } + public CheckBoxProp(SerializedProperty property, Options desc) : this(property, () => Msg(desc)) + { + } + + public CheckBoxProp(SerializedProperty property, string desc) : this(property, () => desc) + { + } + public void Draw() { EditorGUILayout.PropertyField(Property); - EditorGUILayout.HelpBox(Description, MessageType.None); + EditorGUILayout.HelpBox(Description(), MessageType.None); EditorGUILayout.Space(); } } @@ -83,32 +93,56 @@ namespace VRM CheckBoxProp m_reduceBlendShapeClip; CheckBoxProp m_removeVertexColor; + static string Msg(Options key) + { + return M17N.Getter.Msg(key); + } + + enum Options + { + [LangMsg(Languages.ja, "エクスポート時に強制的にT-Pose化する。これを使わずに手動でT-Poseを作っても問題ありません")] + [LangMsg(Languages.en, "Force T-Pose before export. Manually making T-Pose for model without enabling this is ok")] + FORCE_T_POSE, + + [LangMsg(Languages.ja, "エクスポート時に正規化(ヒエラルキーから回転と拡大縮小を取り除くためにベイク)する")] + [LangMsg(Languages.en, "Model's normalization (bake to remove roation and scaling from the hierarchy)")] + NORMALIZE, + + [LangMsg(Languages.ja, "エクスポート時に新しいJsonSerializerを使う")] + [LangMsg(Languages.en, "The new version of JsonSerializer for model export")] + USE_GENERATED_SERIALIZER, + + [LangMsg(Languages.ja, "BlendShapeの容量を GLTF の Sparse Accessor 機能で削減する。修正中: UniGLTF以外でロードできません")] + [LangMsg(Languages.en, "BlendShape size can be reduced by using Sparse Accessor")] + BLENDSHAPE_USE_SPARSE, + + [LangMsg(Languages.ja, "BlendShapeClipのエクスポートに法線とTangentを含めない。UniVRM-0.53 以前ではロードがエラーになるのに注意してください")] + [LangMsg(Languages.en, "BlendShape's Normal and Tangent will not be exported. Be aware that errors may occur during import if the model is made by UniVRM-0.53 or earlier versions")] + BLENDSHAPE_EXCLUDE_NORMAL_AND_TANGENT, + + [LangMsg(Languages.ja, "BlendShapeClipから参照されないBlendShapeをエクスポートに含めない")] + [LangMsg(Languages.en, "BlendShapes that are not referenced by BlendShapeClips will not be exported")] + BLENDSHAPE_ONLY_CLIP_USE, + + [LangMsg(Languages.ja, "BlendShapeClip.Preset == Unknown のBlendShapeClipをエクスポートに含めない")] + [LangMsg(Languages.en, "BlendShapeClip will not be exported if BlendShapeClip.Preset == Unknown")] + BLENDSHAPE_EXCLUDE_UNKNOWN, + + [LangMsg(Languages.ja, "エクスポートに頂点カラーを含めない")] + [LangMsg(Languages.en, "Vertex color will not be exported")] + REMOVE_VERTEX_COLOR, + } + private void OnEnable() { - m_forceTPose = new CheckBoxProp(serializedObject.FindProperty(nameof(ForceTPose)), - "エクスポート時に強制的にT-Pose化する。これを使わずに手動でT-Poseを作っても問題ありません \n" + - "Force T-Pose before export. Manually making T-Pose for model without enabling this is ok"); - m_poseFreeze = new CheckBoxProp(serializedObject.FindProperty(nameof(PoseFreeze)), - "エクスポート時に正規化(ヒエラルキーから回転と拡大縮小を取り除くためにベイク)する \n" + - "Model's normalization (bake to remove roation and scaling from the hierarchy)"); - m_useExcperimentalExporter = new CheckBoxProp(serializedObject.FindProperty(nameof(UseExperimentalExporter)), - "エクスポート時に新しいJsonSerializerを使う \n" + - "The new version of JsonSerializer for model export"); - m_useSparseAccessor = new CheckBoxProp(serializedObject.FindProperty(nameof(UseSparseAccessor)), - "BlendShapeの容量を GLTF の Sparse Accessor 機能で削減する。修正中: UniGLTF以外でロードできません \n" + - "BlendShape size can be reduced by using Sparse Accessor"); - m_onlyBlendShapePosition = new CheckBoxProp(serializedObject.FindProperty(nameof(OnlyBlendshapePosition)), - "BlendShapeClipのエクスポートに法線とTangentを含めない。UniVRM-0.53 以前ではロードがエラーになるのに注意してください \n" + - "BlendShape's Normal and Tangent will not be exported. Be aware that errors may occur during import if the model is made by UniVRM-0.53 or earlier versions"); - m_reduceBlendShape = new CheckBoxProp(serializedObject.FindProperty(nameof(ReduceBlendshape)), - "BlendShapeClipから参照されないBlendShapeをエクスポートに含めない \n" + - "BlendShapes that are not referenced by BlendShapeClips will not be exported"); - m_reduceBlendShapeClip = new CheckBoxProp(serializedObject.FindProperty(nameof(ReduceBlendshapeClip)), - "BlendShapeClip.Preset == Unknown のBlendShapeClipをエクスポートに含めない \n" + - "BlendShapeClip will not be exported if BlendShapeClip.Preset == Unknown"); - m_removeVertexColor = new CheckBoxProp(serializedObject.FindProperty(nameof(RemoveVertexColor)), - "エクスポートに頂点カラーを含めない \n" + - "Vertex color will not be exported"); + m_forceTPose = new CheckBoxProp(serializedObject.FindProperty(nameof(ForceTPose)), Options.FORCE_T_POSE); + m_poseFreeze = new CheckBoxProp(serializedObject.FindProperty(nameof(PoseFreeze)), Options.NORMALIZE); + m_useExcperimentalExporter = new CheckBoxProp(serializedObject.FindProperty(nameof(UseExperimentalExporter)), Options.USE_GENERATED_SERIALIZER); + m_useSparseAccessor = new CheckBoxProp(serializedObject.FindProperty(nameof(UseSparseAccessor)), Options.BLENDSHAPE_USE_SPARSE); + m_onlyBlendShapePosition = new CheckBoxProp(serializedObject.FindProperty(nameof(OnlyBlendshapePosition)), Options.BLENDSHAPE_EXCLUDE_NORMAL_AND_TANGENT); + m_reduceBlendShape = new CheckBoxProp(serializedObject.FindProperty(nameof(ReduceBlendshape)), Options.BLENDSHAPE_ONLY_CLIP_USE); + m_reduceBlendShapeClip = new CheckBoxProp(serializedObject.FindProperty(nameof(ReduceBlendshapeClip)), Options.BLENDSHAPE_EXCLUDE_UNKNOWN); + m_removeVertexColor = new CheckBoxProp(serializedObject.FindProperty(nameof(RemoveVertexColor)), Options.REMOVE_VERTEX_COLOR); } public override void OnInspectorGUI()