From fa36757bd76d64a66c11591a8ca5d50453959932 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 00:40:54 +0900 Subject: [PATCH 01/15] chore: initial commit for internationalization --- Editor/Localizations.cs | 11 +++++++++++ Editor/Localizations.cs.meta | 3 +++ Editor/com.anatawa12.avatar-optimizer.editor.asmdef | 2 ++ Internal/PrefabSafeSet/Editor/asssembly-info.cs | 1 + ...r-optimizer.internal.prefab-safe-set.editor.asmdef | 1 + Internal/PrefabSafeSet/Runtime/assembly-info.cs | 1 + ...2.avatar-optimizer.internal.prefab-safe-set.asmdef | 4 +++- Localization.meta | 3 +++ Localization/en.po | 3 +++ Localization/en.po.meta | 3 +++ Runtime/assembly-info.cs | 1 + Runtime/com.anatawa12.avatar-optimizer.runtime.asmdef | 1 + package.json | 1 + 13 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Editor/Localizations.cs create mode 100644 Editor/Localizations.cs.meta create mode 100644 Localization.meta create mode 100644 Localization/en.po create mode 100644 Localization/en.po.meta diff --git a/Editor/Localizations.cs b/Editor/Localizations.cs new file mode 100644 index 000000000..b458e89e2 --- /dev/null +++ b/Editor/Localizations.cs @@ -0,0 +1,11 @@ +using CustomLocalization4EditorExtension; + +namespace Anatawa12.AvatarOptimizer +{ + static class Localizations + { + [AssemblyCL4EELocalization] + public static Localization Localization { get; } = new Localization( + "8b53df9f2e18428bbba2165c4f2af9be", "en"); + } +} diff --git a/Editor/Localizations.cs.meta b/Editor/Localizations.cs.meta new file mode 100644 index 000000000..f45442bab --- /dev/null +++ b/Editor/Localizations.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8efc3b7bb0bc4cb0a8f13ef22bd14526 +timeCreated: 1679757213 \ No newline at end of file diff --git a/Editor/com.anatawa12.avatar-optimizer.editor.asmdef b/Editor/com.anatawa12.avatar-optimizer.editor.asmdef index 3ad4a2fee..8e867ca93 100644 --- a/Editor/com.anatawa12.avatar-optimizer.editor.asmdef +++ b/Editor/com.anatawa12.avatar-optimizer.editor.asmdef @@ -1,6 +1,8 @@ { "name": "com.anatawa12.avatar-optimizer.editor", "references": [ + "GUID:295ffbe0b63504ae3a7879cf089501ba", + "GUID:8264e72376854221affe9980c91c2fff", "GUID:f69eeb3e25674f4a9bd20e6d7e69e0e6", "GUID:2633ab9fa94544a69517fc9a1bc143c9", "GUID:b9880ca0b6584453a2627bd3c038759f", diff --git a/Internal/PrefabSafeSet/Editor/asssembly-info.cs b/Internal/PrefabSafeSet/Editor/asssembly-info.cs index e86dff41d..bf5337cb7 100644 --- a/Internal/PrefabSafeSet/Editor/asssembly-info.cs +++ b/Internal/PrefabSafeSet/Editor/asssembly-info.cs @@ -1,3 +1,4 @@ using System.Runtime.CompilerServices; [assembly:InternalsVisibleTo("com.anatawa12.avatar-optimizer.test")] +[assembly:CustomLocalization4EditorExtension.RedirectCL4EEInstance("com.anatawa12.avatar-optimizer.editor")] diff --git a/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef b/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef index 9ad0af2fb..8ac59f206 100644 --- a/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef +++ b/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef @@ -1,6 +1,7 @@ { "name": "com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor", "references": [ + "GUID:8264e72376854221affe9980c91c2fff", "GUID:8542dbf824204440a818dbc2377cb4d6" ], "includePlatforms": [ diff --git a/Internal/PrefabSafeSet/Runtime/assembly-info.cs b/Internal/PrefabSafeSet/Runtime/assembly-info.cs index 51a07a35a..aacadf476 100644 --- a/Internal/PrefabSafeSet/Runtime/assembly-info.cs +++ b/Internal/PrefabSafeSet/Runtime/assembly-info.cs @@ -2,3 +2,4 @@ [assembly:InternalsVisibleTo("com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor")] [assembly:InternalsVisibleTo("com.anatawa12.avatar-optimizer.test")] +[assembly:CustomLocalization4EditorExtension.RedirectCL4EEInstance("com.anatawa12.avatar-optimizer.editor")] diff --git a/Internal/PrefabSafeSet/Runtime/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.asmdef b/Internal/PrefabSafeSet/Runtime/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.asmdef index 43c1ecc57..e810254fb 100644 --- a/Internal/PrefabSafeSet/Runtime/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.asmdef +++ b/Internal/PrefabSafeSet/Runtime/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.asmdef @@ -1,6 +1,8 @@ { "name": "com.anatawa12.avatar-optimizer.internal.prefab-safe-set", - "references": [], + "references": [ + "GUID:8264e72376854221affe9980c91c2fff" + ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/Localization.meta b/Localization.meta new file mode 100644 index 000000000..96a05ec47 --- /dev/null +++ b/Localization.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8b53df9f2e18428bbba2165c4f2af9be +timeCreated: 1679754979 \ No newline at end of file diff --git a/Localization/en.po b/Localization/en.po new file mode 100644 index 000000000..5d9caa0b8 --- /dev/null +++ b/Localization/en.po @@ -0,0 +1,3 @@ +msgid "" +msgstr "" +"Language: en\n" diff --git a/Localization/en.po.meta b/Localization/en.po.meta new file mode 100644 index 000000000..9f80737ef --- /dev/null +++ b/Localization/en.po.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f9d382355a0a485980e8e7271bca53d7 +timeCreated: 1679754988 \ No newline at end of file diff --git a/Runtime/assembly-info.cs b/Runtime/assembly-info.cs index 1abdbcf68..8168958ce 100644 --- a/Runtime/assembly-info.cs +++ b/Runtime/assembly-info.cs @@ -2,3 +2,4 @@ [assembly:InternalsVisibleTo("com.anatawa12.avatar-optimizer.editor")] [assembly:InternalsVisibleTo("com.anatawa12.avatar-optimizer.test")] +[assembly:CustomLocalization4EditorExtension.RedirectCL4EEInstance("com.anatawa12.avatar-optimizer.editor")] diff --git a/Runtime/com.anatawa12.avatar-optimizer.runtime.asmdef b/Runtime/com.anatawa12.avatar-optimizer.runtime.asmdef index ca2b498bc..880adf965 100644 --- a/Runtime/com.anatawa12.avatar-optimizer.runtime.asmdef +++ b/Runtime/com.anatawa12.avatar-optimizer.runtime.asmdef @@ -1,6 +1,7 @@ { "name": "com.anatawa12.avatar-optimizer.runtime", "references": [ + "GUID:8264e72376854221affe9980c91c2fff", "GUID:8542dbf824204440a818dbc2377cb4d6", "GUID:c85616d79bd2a41109c251ab53d14c20" ], diff --git a/package.json b/package.json index 97bc4ca33..055b34e23 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/anatawa12/AvatarOptimizer", "repo": "https://vpm.anatawa12.com/vpm.json", "vpmDependencies": { + "com.anatawa12.custom-localization-for-editor-extension": "^0.2.2", "com.vrchat.avatars": ">=3.1.10 <4.0.0" } } From 1970f3812fe9a7db8ec1e64dc9e33456cc475298 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 00:42:05 +0900 Subject: [PATCH 02/15] chore(i18n): for MergeSkinnedMesh --- Editor/MergeSkinnedMeshEditor.cs | 45 ++++---------------------------- Localization/en.po | 27 +++++++++++++++++++ Runtime/MergeSkinnedMesh.cs | 4 +++ 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/Editor/MergeSkinnedMeshEditor.cs b/Editor/MergeSkinnedMeshEditor.cs index 6dc36a77c..e6b12866c 100644 --- a/Editor/MergeSkinnedMeshEditor.cs +++ b/Editor/MergeSkinnedMeshEditor.cs @@ -1,9 +1,8 @@ -using System; using System.Collections.Generic; using System.Linq; +using CustomLocalization4EditorExtension; using UnityEditor; using UnityEngine; -using Object = UnityEngine.Object; namespace Anatawa12.AvatarOptimizer { @@ -49,9 +48,7 @@ public override void OnInspectorGUI() _saveVersion.Draw(serializedObject); if (((MergeSkinnedMesh)target).GetComponent().sharedMesh) { - GUILayout.Label($"Mesh of SkinnedMeshRenderer is not None!", Style.WarningStyle); - GUILayout.Label($"You should add MergeSkinnedMesh onto new GameObject with new SkinnedMeshRenderer!", - Style.WarningStyle); + EditorGUILayout.HelpBox(CL4EE.Tr("MergeSkinnedMesh:warning:MeshIsNotNone"), MessageType.Warning); } EditorGUILayout.PropertyField(_renderersSetProp); @@ -60,45 +57,13 @@ public override void OnInspectorGUI() serializedObject.ApplyModifiedProperties(); - EditorGUILayout.LabelField("Merge Materials:", EditorStyles.boldLabel); + EditorGUILayout.LabelField(CL4EE.Tr("MergeSkinnedMesh:label:Merge Materials"), EditorStyles.boldLabel); if (targets.Length != 1) EditorGUILayout.LabelField("MergeMaterial is not supported with Multi Target Editor"); else MergeMaterials((MergeSkinnedMesh)target); } - public void ShowRenderers(string property, SerializedProperty array, Action validation) - where T : Object - { - EditorGUILayout.LabelField(property, EditorStyles.boldLabel); - - EditorGUI.indentLevel++; - for (var i = 0; i < array.arraySize; i++) - { - var elementProp = array.GetArrayElementAtIndex(i); - EditorGUILayout.PropertyField(elementProp); - - if (elementProp.objectReferenceValue == null) - { - array.DeleteArrayElementAtIndex(i); - i--; - } - else if (elementProp.objectReferenceValue is T renderer) - { - validation(renderer); - } - } - - var toAdd = (T)EditorGUILayout.ObjectField($"Element {array.arraySize}", null, typeof(T), true); - if (toAdd != null) - { - array.arraySize += 1; - array.GetArrayElementAtIndex(array.arraySize - 1).objectReferenceValue = toAdd; - } - - EditorGUI.indentLevel--; - } - public void MergeMaterials(MergeSkinnedMesh merge) { var materials = new HashSet(); @@ -123,11 +88,11 @@ public void MergeMaterials(MergeSkinnedMesh merge) EditorGUI.indentLevel++; var element = _doNotMergeMaterials.GetElementOf(group.Key); var fieldPosition = EditorGUILayout.GetControlRect(); - var label = new GUIContent("Merge"); + var label = new GUIContent(CL4EE.Tr("MergeSkinnedMesh:label:Merge")); using (new PrefabSafeSet.PropertyScope(element, fieldPosition, label)) element.SetExistence(!EditorGUI.ToggleLeft(fieldPosition, label, !element.Contains)); - EditorGUILayout.LabelField("Renderers:"); + EditorGUILayout.LabelField(CL4EE.Tr("MergeSkinnedMesh:label:Renderers")); EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(true); foreach (var (_, rendererIndex, _) in group) diff --git a/Localization/en.po b/Localization/en.po index 5d9caa0b8..1fd7d764b 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -1,3 +1,30 @@ msgid "" msgstr "" "Language: en\n" + +# region MergeSkinnedMesh + +msgid "MergeSkinnedMesh:warning:MeshIsNotNone" +msgstr "" +""Mesh of SkinnedMeshRenderer is not None!\n" +"You should add MergeSkinnedMesh onto new GameObject with new SkinnedMeshRenderer!" + +msgid "MergeSkinnedMesh:prop:renderers" +msgstr "Skinned Renderers" + +msgid "MergeSkinnedMesh:prop:staticRenderers" +msgstr "Static Renderers" + +msgid "MergeSkinnedMesh:prop:removeEmptyRendererObject" +msgstr "Remove Empty Renderer Object" + +msgid "MergeSkinnedMesh:label:Merge Materials" +msgstr "Merge Materials" + +msgid "MergeSkinnedMesh:label:Merge" +msgstr "Merge" + +msgid "MergeSkinnedMesh:label:Renderers" +msgstr "Renderers:" + +# endregion diff --git a/Runtime/MergeSkinnedMesh.cs b/Runtime/MergeSkinnedMesh.cs index 5b51c5ad8..e711b73ec 100644 --- a/Runtime/MergeSkinnedMesh.cs +++ b/Runtime/MergeSkinnedMesh.cs @@ -1,4 +1,5 @@ using System; +using CustomLocalization4EditorExtension; using UnityEngine; namespace Anatawa12.AvatarOptimizer @@ -27,12 +28,15 @@ public class MergeConfig #endregion #region v2 + [CL4EELocalized("MergeSkinnedMesh:prop:renderers")] public PrefabSafeSet.SkinnedMeshRendererSet renderersSet; + [CL4EELocalized("MergeSkinnedMesh:prop:staticRenderers")] public PrefabSafeSet.MeshRendererSet staticRenderersSet; public PrefabSafeSet.MaterialSet doNotMergeMaterials; #endregion // common between v0 and v1 + [CL4EELocalized("MergeSkinnedMesh:prop:removeEmptyRendererObject")] [ToggleLeft] public bool removeEmptyRendererObject; From 7c93f20c1996a8d0bd07b903dd65faae4af6aec7 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 00:55:46 +0900 Subject: [PATCH 03/15] chore(i18n): for FreezeBlendShape --- Editor/FreezeBlendShapeEditor.cs | 11 +++-------- Localization/en.po | 10 ++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Editor/FreezeBlendShapeEditor.cs b/Editor/FreezeBlendShapeEditor.cs index a056071af..2d5230a27 100644 --- a/Editor/FreezeBlendShapeEditor.cs +++ b/Editor/FreezeBlendShapeEditor.cs @@ -1,3 +1,4 @@ +using CustomLocalization4EditorExtension; using UnityEditor; using UnityEngine; @@ -21,12 +22,6 @@ private void OnEnable() public override void OnInspectorGUI() { - if (targets.Length != 1) - { - EditorGUILayout.LabelField("MultiTarget Editing is not supported"); - return; - } - _saveVersion.Draw(serializedObject); var component = (FreezeBlendShape)target; @@ -47,13 +42,13 @@ public override void OnInspectorGUI() using (new GUILayout.HorizontalScope()) { - if (GUILayout.Button("Check All")) + if (GUILayout.Button(CL4EE.Tr("FreezeBlendShape:button:Check All"))) { foreach (var shapeKeyName in shapes) _shapeKeysSet.GetElementOf(shapeKeyName).EnsureAdded(); } - if (GUILayout.Button("Invert All")) + if (GUILayout.Button(CL4EE.Tr("FreezeBlendShape:button:Invert All"))) { foreach (var shapeKeyName in shapes) { diff --git a/Localization/en.po b/Localization/en.po index 1fd7d764b..216e6c990 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -2,6 +2,16 @@ msgid "" msgstr "" "Language: en\n" +# region FreezeBlendShape + +msgid "FreezeBlendShape:button:Check All" +msgstr "Check All" + +msgid "FreezeBlendShape:button:Invert All" +msgstr "Invert All" + +# endregion + # region MergeSkinnedMesh msgid "MergeSkinnedMesh:warning:MeshIsNotNone" From 70a1545c453e4a859fec858ec4d0cbb47dab187e Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 02:26:18 +0900 Subject: [PATCH 04/15] chore(i18n): for PrefabSafeSet --- .../Editor/PrefabSafeSetEditor.cs | 30 +++++++++----- ...zer.internal.prefab-safe-set.editor.asmdef | 1 + Localization/en.po | 40 +++++++++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/Internal/PrefabSafeSet/Editor/PrefabSafeSetEditor.cs b/Internal/PrefabSafeSet/Editor/PrefabSafeSetEditor.cs index 9ec7de5d5..398d0cbb2 100644 --- a/Internal/PrefabSafeSet/Editor/PrefabSafeSetEditor.cs +++ b/Internal/PrefabSafeSet/Editor/PrefabSafeSetEditor.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CustomLocalization4EditorExtension; using JetBrains.Annotations; using UnityEditor; using UnityEngine; @@ -9,18 +10,23 @@ namespace Anatawa12.AvatarOptimizer.PrefabSafeSet { internal static class EditorStatics { - public static readonly GUIContent MultiEditingNotSupported = new GUIContent("Multi editing not supported"); - public static readonly GUIContent UnsupportedType = new GUIContent("Element type is not supported"); - public static readonly GUIContent AddNotSupported = new GUIContent("Add Not Supported"); + public static readonly GUIContent MultiEditingNotSupported = + new GUIContent(CL4EE.Tr("PrefabSafeSet:label:Multi editing not supported")); - public static readonly GUIContent ToAdd = new GUIContent("Element to add") + public static readonly GUIContent UnsupportedType = + new GUIContent(CL4EE.Tr("PrefabSafeSet:label:Element type is not supported")); + + public static readonly GUIContent AddNotSupported = + new GUIContent(CL4EE.Tr("PrefabSafeSet:label:Add Not Supported")); + + public static readonly GUIContent ToAdd = new GUIContent(CL4EE.Tr("PrefabSafeSet:label:Element to add")) { - tooltip = "Drag & Drop value to here to add element to this set." + tooltip = CL4EE.Tr("PrefabSafeSet:tooltip:Element to add") }; public static readonly GUIContent ForceAddButton = new GUIContent("+") { - tooltip = "Add this element in current prefab modifications." + tooltip = CL4EE.Tr("PrefabSafeSet:tooltip:Force Add Button") }; } @@ -320,23 +326,25 @@ public void OnGUI(Rect position) switch (element.Status) { case ElementStatus.Natural: - newLabel.text = $"Element {elementI++}"; + newLabel.text = string.Format(CL4EE.Tr("PrefabSafeSet:label:Element {0}"), elementI++); fieldModKind = ModificationKind.Natural; break; case ElementStatus.Removed: - newLabel.text = "(Removed)"; + newLabel.text = CL4EE.Tr("PrefabSafeSet:label:(Removed)"); fieldModKind = ModificationKind.Remove; break; case ElementStatus.NewElement: - newLabel.text = $"Element {elementI++}"; + newLabel.text = string.Format(CL4EE.Tr("PrefabSafeSet:label:Element {0}"), elementI++); fieldModKind = ModificationKind.Add; break; case ElementStatus.AddedTwice: - newLabel.text = $"Element {elementI++} (Added twice)"; + newLabel.text = + string.Format(CL4EE.Tr("PrefabSafeSet:label:Element {0} (Added twice)"), elementI++); fieldModKind = ModificationKind.Add; break; case ElementStatus.FakeRemoved: - newLabel.text = "(Removed but not found)"; + newLabel.text = + CL4EE.Tr("PrefabSafeSet:label:(Removed but not found)"); fieldModKind = ModificationKind.Remove; break; default: diff --git a/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef b/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef index 8ac59f206..14cb96343 100644 --- a/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef +++ b/Internal/PrefabSafeSet/Editor/com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor.asmdef @@ -1,6 +1,7 @@ { "name": "com.anatawa12.avatar-optimizer.internal.prefab-safe-set.editor", "references": [ + "GUID:295ffbe0b63504ae3a7879cf089501ba", "GUID:8264e72376854221affe9980c91c2fff", "GUID:8542dbf824204440a818dbc2377cb4d6" ], diff --git a/Localization/en.po b/Localization/en.po index 216e6c990..cd1c2c075 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -2,6 +2,46 @@ msgid "" msgstr "" "Language: en\n" +# region PrefabSafeSet + +msgid "PrefabSafeSet:label:Multi editing not supported" +msgstr "Multi editing not supported" + +msgid "PrefabSafeSet:label:Element type is not supported" +msgstr "Element type is not supported" + +msgid "PrefabSafeSet:label:Add Not Supported" +msgstr "Add Not Supported" + +msgid "PrefabSafeSet:label:Element to add" +msgstr "Element to add" + +msgid "PrefabSafeSet:tooltip:Element to add" +msgstr "Drag & Drop value to here to add element to this set." + +msgid "PrefabSafeSet:tooltip:Force Add Button" +msgstr "Add this element in current prefab modifications." + +# , csharp-format +msgid "PrefabSafeSet:label:Element {0}" +msgstr "Element {0}" + +# , csharp-format +msgid "PrefabSafeSet:label:(Removed)" +msgstr "(Removed)" + +# , csharp-format +msgid "PrefabSafeSet:label:Element {0} (Added twice)" +msgstr "Element {0} (Added twice)" + +# , csharp-format +msgid "PrefabSafeSet:label:(Removed but not found)" +msgstr "(Removed but not found)" + +# endregion + +# start Avatar Optimizer core modules + # region FreezeBlendShape msgid "FreezeBlendShape:button:Check All" From 9e87764fc7335660df0df6ae029aca9c6cd800d8 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 02:30:02 +0900 Subject: [PATCH 05/15] ci: add anatawa12's vpm repo --- .github/workflows/gameci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/gameci.yml b/.github/workflows/gameci.yml index 85122c130..2540aa027 100644 --- a/.github/workflows/gameci.yml +++ b/.github/workflows/gameci.yml @@ -20,6 +20,9 @@ jobs: path: Packages/com.anatawa12.avatar-optimizer ref: ${{ github.event.pull_request.head.sha }} - uses: anatawa12/sh-actions/resolve-vpm-packages@master + with: + driver-opts: | + https://vpm.anatawa12.com/vpm.json - uses: actions/cache@v3 with: From 5f67cb3cc4c4394f2a20a7d6f450cb0786ae7f8a Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 17:06:06 +0900 Subject: [PATCH 06/15] chore(i18n): for ClearEndpointPosition --- Editor/ClearEndpointPositionEditor.cs | 6 +++--- Localization/en.po | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Editor/ClearEndpointPositionEditor.cs b/Editor/ClearEndpointPositionEditor.cs index 4f14cd942..d4da24a5d 100644 --- a/Editor/ClearEndpointPositionEditor.cs +++ b/Editor/ClearEndpointPositionEditor.cs @@ -1,4 +1,5 @@ using Anatawa12.AvatarOptimizer.Processors; +using CustomLocalization4EditorExtension; using UnityEditor; using UnityEngine; using VRC.Dynamics; @@ -11,12 +12,11 @@ internal class ClearEndpointPositionEditor : Editor private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); public override void OnInspectorGUI() { - EditorGUILayout.LabelField("You clear Endpoint Position with _end bones."); - EditorGUILayout.LabelField("This can be useful for MergeBone component"); + EditorGUILayout.HelpBox(CL4EE.Tr("ClearEndpointPosition:description"), MessageType.None); _saveVersion.Draw(serializedObject); - if (GUILayout.Button("Apply and Remove Component")) + if (GUILayout.Button(CL4EE.Tr("ClearEndpointPosition:button:Apply and Remove Component"))) { ClearEndpointPositionProcessor.Process(((Component)target).GetComponent()); DestroyImmediate(target); diff --git a/Localization/en.po b/Localization/en.po index cd1c2c075..2f16c70b1 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -42,6 +42,18 @@ msgstr "(Removed but not found)" # start Avatar Optimizer core modules +# region ClearEndpointPosition + +msgid "ClearEndpointPosition:description" +msgstr "" +"You clear Endpoint Position with _end bones.\n" +"This can be useful for MergeBone component." + +msgid "ClearEndpointPosition:button:Apply and Remove Component" +msgstr "Apply and Remove Component" + +# endregion + # region FreezeBlendShape msgid "FreezeBlendShape:button:Check All" From dfbafd62b787d1ebd321e939b68804181278c1f9 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 17:36:10 +0900 Subject: [PATCH 07/15] chore(i18n): for MakeChildren --- Editor/MakeChildrenEditor.cs | 3 ++- Localization/en.po | 10 ++++++++++ Runtime/MakeChildren.cs | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Editor/MakeChildrenEditor.cs b/Editor/MakeChildrenEditor.cs index 0a9e5ec11..d801f3411 100644 --- a/Editor/MakeChildrenEditor.cs +++ b/Editor/MakeChildrenEditor.cs @@ -1,4 +1,5 @@ using System; +using CustomLocalization4EditorExtension; using UnityEditor; namespace Anatawa12.AvatarOptimizer @@ -17,7 +18,7 @@ private void OnEnable() public override void OnInspectorGUI() { - EditorGUILayout.HelpBox("This component will make children at build time", MessageType.Info); + EditorGUILayout.HelpBox(CL4EE.Tr("MakeChildren:description"), MessageType.None); _saveVersion.Draw(serializedObject); EditorGUILayout.PropertyField(_children); serializedObject.ApplyModifiedProperties(); diff --git a/Localization/en.po b/Localization/en.po index 2f16c70b1..5b82f7904 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -64,6 +64,16 @@ msgstr "Invert All" # endregion +# region MakeChildren + +msgid "MakeChildren:description" +msgstr "This component will make children at build time" + +msgid "MakeChildren:prop:children" +msgstr "Children" + +# endregion + # region MergeSkinnedMesh msgid "MergeSkinnedMesh:warning:MeshIsNotNone" diff --git a/Runtime/MakeChildren.cs b/Runtime/MakeChildren.cs index 1e68e1a88..f7dca04ed 100644 --- a/Runtime/MakeChildren.cs +++ b/Runtime/MakeChildren.cs @@ -1,7 +1,10 @@ +using CustomLocalization4EditorExtension; + namespace Anatawa12.AvatarOptimizer { internal class MakeChildren : AvatarTagComponent { + [CL4EELocalized("MakeChildren:prop:children")] public PrefabSafeSet.TransformSet children; } } From aa1a85c1af7828105c33b5ad7e45e2b434c06bf5 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 17:50:10 +0900 Subject: [PATCH 08/15] chore(i18n): for MergeBone --- Editor/MergeBoneEditor.cs | 3 ++- Localization/en.po | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Editor/MergeBoneEditor.cs b/Editor/MergeBoneEditor.cs index 8121fe518..7208b3e5b 100644 --- a/Editor/MergeBoneEditor.cs +++ b/Editor/MergeBoneEditor.cs @@ -1,3 +1,4 @@ +using CustomLocalization4EditorExtension; using UnityEditor; namespace Anatawa12.AvatarOptimizer @@ -8,7 +9,7 @@ public class MergeBoneEditor : Editor private SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); public override void OnInspectorGUI() { - EditorGUILayout.LabelField("You will remove this GameObject and merge bone to parent"); + EditorGUILayout.HelpBox(CL4EE.Tr("MergeBone:description"), MessageType.None); _saveVersion.Draw(serializedObject); } } diff --git a/Localization/en.po b/Localization/en.po index 5b82f7904..88e287974 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -74,6 +74,13 @@ msgstr "Children" # endregion +# region MergeBone + +msgid "MergeBone:description" +msgstr "You will remove this GameObject and merge bone to parent" + +# endregion + # region MergeSkinnedMesh msgid "MergeSkinnedMesh:warning:MeshIsNotNone" From 535731a1a9febfe2641297c2a1eab6a97d4461d7 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 18:07:51 +0900 Subject: [PATCH 09/15] chore(i18n): for MergePhysBone --- Editor/MergePhysBoneEditor.cs | 4 +- Localization/en.po | 70 +++++++++++++++++++++++++++++++++++ Runtime/MergePhysBone.cs | 31 ++++++++++++++-- 3 files changed, 100 insertions(+), 5 deletions(-) diff --git a/Editor/MergePhysBoneEditor.cs b/Editor/MergePhysBoneEditor.cs index 33f638eca..ee9c05097 100644 --- a/Editor/MergePhysBoneEditor.cs +++ b/Editor/MergePhysBoneEditor.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using CustomLocalization4EditorExtension; using UnityEditor; using UnityEngine; using VRC.Dynamics; @@ -116,7 +117,8 @@ public override void OnInspectorGUI() break; case VRCPhysBoneBase.LimitType.Angle: case VRCPhysBoneBase.LimitType.Hinge: - EditorGUILayout.PropertyField(_maxAngleXProp, new GUIContent("Max Angle")); + EditorGUILayout.PropertyField(_maxAngleXProp, + new GUIContent(CL4EE.Tr("MergePhysBone:prop:Max Angle"))); EditorGUILayout.PropertyField(_limitRotationProp); break; case VRCPhysBoneBase.LimitType.Polar: diff --git a/Localization/en.po b/Localization/en.po index 88e287974..fd241363d 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -81,6 +81,76 @@ msgstr "You will remove this GameObject and merge bone to parent" # endregion +# region + +msgid "MergePhysBone:prop:merged" +msgstr "Merged" + +msgid "MergePhysBone:prop:forces" +msgstr "Forces" + +msgid "MergePhysBone:prop:pull" +msgstr "Pull" + +msgid "MergePhysBone:prop:spring" +msgstr "Spring" + +msgid "MergePhysBone:prop:stiffness" +msgstr "Stiffness" + +msgid "MergePhysBone:prop:gravity" +msgstr "Gravity" + +msgid "MergePhysBone:prop:gravityFalloff" +msgstr "Gravity Falloff" + +msgid "MergePhysBone:prop:immobile" +msgstr "Immobile" + +msgid "MergePhysBone:prop:limits" +msgstr "Limits" + +msgid "MergePhysBone:prop:maxAngleX" +msgstr "Max Angle X" + +msgid "MergePhysBone:prop:Max Angle" +msgstr "Max Angle" + +msgid "MergePhysBone:prop:maxAngleZ" +msgstr "Max Angle Z" + +msgid "MergePhysBone:prop:limitRotation" +msgstr "Limit Rotation" + +msgid "MergePhysBone:prop:radius" +msgstr "Radius" + +msgid "MergePhysBone:prop:allowCollision" +msgstr "Allow Collision" + +msgid "MergePhysBone:prop:colliders" +msgstr "Colliders" + +msgid "MergePhysBone:prop:allowGrabbing" +msgstr "Allow Grabbing" + +msgid "MergePhysBone:prop:grabMovement" +msgstr "Grab Movement" + +msgid "MergePhysBone:prop:allowPosing" +msgstr "Allow Posing" + +msgid "MergePhysBone:prop:maxStretch" +msgstr "Max Stretch" + +msgid "MergePhysBone:prop:isAnimated" +msgstr "Is Animated" + +msgid "MergePhysBone:prop:components" +msgstr "Components" + +# endregion + # region MergeSkinnedMesh msgid "MergeSkinnedMesh:warning:MeshIsNotNone" diff --git a/Runtime/MergePhysBone.cs b/Runtime/MergePhysBone.cs index 78bc17947..9b828767a 100644 --- a/Runtime/MergePhysBone.cs +++ b/Runtime/MergePhysBone.cs @@ -1,4 +1,5 @@ using System; +using CustomLocalization4EditorExtension; using UnityEngine; using UnityEngine.Serialization; using VRC.Dynamics; @@ -12,38 +13,60 @@ namespace Anatawa12.AvatarOptimizer [ExecuteAlways] internal class MergePhysBone : AvatarTagComponent { - [FormerlySerializedAs("mergedComponent")] public VRCPhysBoneBase merged; + [FormerlySerializedAs("mergedComponent")] + [CL4EELocalized("MergePhysBone:prop:merged")] + public VRCPhysBoneBase merged; public Transform rootTransform; // == Forces == - [FormerlySerializedAs("force")] public bool forces; + [FormerlySerializedAs("force")] [CL4EELocalized("MergePhysBone:prop:forces")] + public bool forces; + [CL4EELocalized("MergePhysBone:prop:pull")] public bool pull; + [CL4EELocalized("MergePhysBone:prop:spring")] public bool spring; + [CL4EELocalized("MergePhysBone:prop:stiffness")] public bool stiffness; + [CL4EELocalized("MergePhysBone:prop:gravity")] public bool gravity; + [CL4EELocalized("MergePhysBone:prop:gravityFalloff")] public bool gravityFalloff; + [CL4EELocalized("MergePhysBone:prop:immobile")] public bool immobile; // == Limits == + [CL4EELocalized("MergePhysBone:prop:limits")] public bool limits; + [CL4EELocalized("MergePhysBone:prop:maxAngleX")] public bool maxAngleX; + [CL4EELocalized("MergePhysBone:prop:maxAngleZ")] public bool maxAngleZ; + [CL4EELocalized("MergePhysBone:prop:limitRotation")] public bool limitRotation; // == Collision == + [CL4EELocalized("MergePhysBone:prop:radius")] public bool radius; + [CL4EELocalized("MergePhysBone:prop:allowCollision")] public bool allowCollision; + [CL4EELocalized("MergePhysBone:prop:colliders")] public CollidersSettings colliders; // == Grab & Pose == + [CL4EELocalized("MergePhysBone:prop:allowGrabbing")] public bool allowGrabbing; + [CL4EELocalized("MergePhysBone:prop:grabMovement")] public bool grabMovement; + [CL4EELocalized("MergePhysBone:prop:allowPosing")] public bool allowPosing; + [CL4EELocalized("MergePhysBone:prop:maxStretch")] public bool maxStretch; // == Others == // public bool overrideParameter; Always + [CL4EELocalized("MergePhysBone:prop:isAnimated")] public bool isAnimated; - [Obsolete("legacy v1", true)] - [FormerlySerializedAs("component")] public VRCPhysBoneBase[] components; + [Obsolete("legacy v1", true)] [FormerlySerializedAs("component")] + public VRCPhysBoneBase[] components; + [CL4EELocalized("MergePhysBone:prop:components")] public PrefabSafeSet.VRCPhysBoneBaseSet componentsSet; public MergePhysBone() From a7237da493a72a275ebc4008b943c239125fd609 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 18:18:55 +0900 Subject: [PATCH 10/15] chore(i18n): for MergeToonLitMaterial --- Editor/MergeToonLitMaterialEditor.cs | 18 ++++++------------ Localization/en.po | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Editor/MergeToonLitMaterialEditor.cs b/Editor/MergeToonLitMaterialEditor.cs index 6505876b5..2706e66f9 100644 --- a/Editor/MergeToonLitMaterialEditor.cs +++ b/Editor/MergeToonLitMaterialEditor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Anatawa12.AvatarOptimizer.Processors.SkinnedMeshes; +using CustomLocalization4EditorExtension; using UnityEditor; using UnityEngine; using Debug = System.Diagnostics.Debug; @@ -96,24 +97,17 @@ private static void DrawList( public override void OnInspectorGUI() { - EditorGUILayout.LabelField("The component to merge multiple VRChat ToonLit materials."); - EditorGUILayout.LabelField("This is for quest avoid limitation"); + EditorGUILayout.HelpBox(CL4EE.Tr("MergeToonLitMaterial:description"), MessageType.None); _saveVersion.Draw(serializedObject); - if (targets.Length != 1) - { - EditorGUILayout.LabelField("MultiTarget Editing is not supported"); - return; - } - EditorGUI.BeginChangeCheck(); var component = (MergeToonLitMaterial)target; - DrawList(ref component.merges, "Add Merged Material", (componentMerge, i) => + DrawList(ref component.merges, CL4EE.Tr("MergeToonLitMaterial:button:Add Merged Material"), (componentMerge, i) => { - DrawList(ref componentMerge.source, "Add Source", (mergeSource, _2) => + DrawList(ref componentMerge.source, CL4EE.Tr("MergeToonLitMaterial:button:Add Source"), (mergeSource, _2) => { var found = _materials.FirstOrDefault(x => x.index == mergeSource.materialIndex); _candidateNames[0] = found.mat != null ? found.mat.name : "(invalid)"; @@ -132,7 +126,7 @@ public override void OnInspectorGUI() ); componentMerge.textureSize = - EditorGUILayout.Vector2IntField("Texture Size", componentMerge.textureSize); + EditorGUILayout.Vector2IntField(CL4EE.Tr("MergeToonLitMaterial:label:Texture Size"), componentMerge.textureSize); var preview = _generatedPreviews != null ? _generatedPreviews[i] : Utils.PreviewHereTex; EditorGUILayout.LabelField(new GUIContent(preview), GUILayout.MaxHeight(256), GUILayout.MaxHeight(256)); @@ -149,7 +143,7 @@ public override void OnInspectorGUI() if (EditorGUI.EndChangeCheck()) OnChanged(); - if (GUILayout.Button("Generate Preview")) + if (GUILayout.Button(CL4EE.Tr("MergeToonLitMaterial:button:Generate Preview"))) { _generatedPreviews = MergeToonLitMaterialProcessor.GenerateTextures(component, _upstreamMaterials); } diff --git a/Localization/en.po b/Localization/en.po index fd241363d..34e1e4f77 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -177,3 +177,24 @@ msgid "MergeSkinnedMesh:label:Renderers" msgstr "Renderers:" # endregion + +# region MergeToonLitMaterial + +msgid "MergeToonLitMaterial:description" +msgstr "" +"The component to merge multiple VRChat ToonLit materials.\n" +"This is for quest avoid limitation" + +msgid "MergeToonLitMaterial:button:Add Merged Material" +msgstr "Add Merged Material" + +msgid "MergeToonLitMaterial:button:Add Source" +msgstr "Add Source" + +msgid "MergeToonLitMaterial:button:Generate Preview" +msgstr "Generate Preview" + +msgid "MergeToonLitMaterial:label:Texture Size" +msgstr "Texture Size" + +# endregion From 97f93ca431034dadd3bf6f849f7505e3574a95b4 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 18:24:42 +0900 Subject: [PATCH 11/15] chore(i18n): for RemoveMeshInBox --- Localization/en.po | 13 +++++++++++++ Runtime/RemoveMeshInBox.cs | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/Localization/en.po b/Localization/en.po index 34e1e4f77..76119470c 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -198,3 +198,16 @@ msgid "MergeToonLitMaterial:label:Texture Size" msgstr "Texture Size" # endregion + +# region RemoveMeshInBox + +msgid "RemoveMeshInBox:BoundingBox:prop:center" +msgstr "Center" + +msgid "RemoveMeshInBox:BoundingBox:prop:size" +msgstr "Size" + +msgid "RemoveMeshInBox:BoundingBox:prop:rotation" +msgstr "Rotation" + +# endregion diff --git a/Runtime/RemoveMeshInBox.cs b/Runtime/RemoveMeshInBox.cs index 0a7242e64..1e1f8648c 100644 --- a/Runtime/RemoveMeshInBox.cs +++ b/Runtime/RemoveMeshInBox.cs @@ -1,5 +1,6 @@ using System; using Anatawa12.AvatarOptimizer.PrefabSafeList; +using CustomLocalization4EditorExtension; using UnityEngine; using Object = UnityEngine.Object; @@ -23,8 +24,11 @@ public RemoveMeshInBox() [Serializable] public class BoundingBox { + [CL4EELocalized("RemoveMeshInBox:BoundingBox:prop:center")] public Vector3 center; + [CL4EELocalized("RemoveMeshInBox:BoundingBox:prop:size")] public Vector3 size = new Vector3(1, 1, 1); + [CL4EELocalized("RemoveMeshInBox:BoundingBox:prop:rotation")] public Quaternion rotation = Quaternion.identity; public bool ContainsVertex(Vector3 point) From 618e14a9856bb503e3ad2cb36ef4bec3973b8ba7 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 18:53:57 +0900 Subject: [PATCH 12/15] feat(internal): add AvatarTagComponentEditorBase --- Editor/AvatarTagComponentEditorBase.cs | 45 +++++++++++++++++++ Editor/AvatarTagComponentEditorBase.cs.meta | 3 ++ ...tor.cs => AvatarTagComponentEditorImpl.cs} | 2 +- ...a => AvatarTagComponentEditorImpl.cs.meta} | 0 Runtime/AvatarTagComponent.cs | 2 +- 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 Editor/AvatarTagComponentEditorBase.cs create mode 100644 Editor/AvatarTagComponentEditorBase.cs.meta rename Editor/{AvatarTagComponentEditor.cs => AvatarTagComponentEditorImpl.cs} (96%) rename Editor/{AvatarTagComponentEditor.cs.meta => AvatarTagComponentEditorImpl.cs.meta} (100%) diff --git a/Editor/AvatarTagComponentEditorBase.cs b/Editor/AvatarTagComponentEditorBase.cs new file mode 100644 index 000000000..5543f17ec --- /dev/null +++ b/Editor/AvatarTagComponentEditorBase.cs @@ -0,0 +1,45 @@ +using UnityEditor; + +namespace Anatawa12.AvatarOptimizer +{ + abstract class AvatarTagComponentEditorBase : Editor + { + private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); + + public sealed override void OnInspectorGUI() + { + var description = Description; + if (!string.IsNullOrEmpty(description)) + EditorGUILayout.HelpBox(description, MessageType.None); + + _saveVersion.Draw(serializedObject); + + OnInspectorGUIInner(); + } + + protected abstract string Description { get; } + protected abstract void OnInspectorGUIInner(); + } + + [CustomEditor(typeof(AvatarTagComponent), true)] + class DefaultAvatarTagComponentEditor : AvatarTagComponentEditorBase + { + protected override string Description => null; + + protected override void OnInspectorGUIInner() + { + serializedObject.UpdateIfRequiredOrScript(); + var iterator = serializedObject.GetIterator(); + + var enterChildren = true; + while (iterator.NextVisible(enterChildren)) + { + if ("m_Script" != iterator.propertyPath) + EditorGUILayout.PropertyField(iterator, true); + enterChildren = false; + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Editor/AvatarTagComponentEditorBase.cs.meta b/Editor/AvatarTagComponentEditorBase.cs.meta new file mode 100644 index 000000000..b57086865 --- /dev/null +++ b/Editor/AvatarTagComponentEditorBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f000b18b33194aab9df07c8043ff65fd +timeCreated: 1679823417 \ No newline at end of file diff --git a/Editor/AvatarTagComponentEditor.cs b/Editor/AvatarTagComponentEditorImpl.cs similarity index 96% rename from Editor/AvatarTagComponentEditor.cs rename to Editor/AvatarTagComponentEditorImpl.cs index b6aece879..4fd97fab4 100644 --- a/Editor/AvatarTagComponentEditor.cs +++ b/Editor/AvatarTagComponentEditorImpl.cs @@ -5,7 +5,7 @@ namespace Anatawa12.AvatarOptimizer { [UsedImplicitly] - public class AvatarTagComponentEditor + public class AvatarTagComponentEditorImpl { [UsedImplicitly] public static void SetCurrentSaveVersion(AvatarTagComponent component) diff --git a/Editor/AvatarTagComponentEditor.cs.meta b/Editor/AvatarTagComponentEditorImpl.cs.meta similarity index 100% rename from Editor/AvatarTagComponentEditor.cs.meta rename to Editor/AvatarTagComponentEditorImpl.cs.meta diff --git a/Runtime/AvatarTagComponent.cs b/Runtime/AvatarTagComponent.cs index 9e20c2589..9f49cf3c3 100644 --- a/Runtime/AvatarTagComponent.cs +++ b/Runtime/AvatarTagComponent.cs @@ -19,7 +19,7 @@ public abstract class AvatarTagComponent : MonoBehaviour #if UNITY_EDITOR private static readonly System.Reflection.MethodInfo OnEnableCallback = System.Reflection.Assembly.Load("com.anatawa12.avatar-optimizer.editor") - .GetType("Anatawa12.AvatarOptimizer.AvatarTagComponentEditor") + .GetType("Anatawa12.AvatarOptimizer.AvatarTagComponentEditorImpl") .GetMethod("SetCurrentSaveVersion", new[] { typeof(AvatarTagComponent) }); #endif From 8f54fcc0217b46e482f7678995c05f63dc3babe2 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 20:59:17 +0900 Subject: [PATCH 13/15] chore: rewrite editors with AvatarTagComponentEditorBase --- Editor/AvatarTagComponentEditorBase.cs | 4 +--- Editor/ClearEndpointPositionEditor.cs | 11 ++++------- Editor/FreezeBlendShapeEditor.cs | 7 ++----- Editor/MakeChildrenEditor.cs | 8 +++----- Editor/MergeBoneEditor.cs | 9 ++++----- Editor/MergePhysBoneEditor.cs | 6 ++---- Editor/MergeSkinnedMeshEditor.cs | 6 ++---- Editor/MergeToonLitMaterialEditor.cs | 10 +++------- Editor/RemoveMeshInBoxEditor.cs | 14 ++------------ 9 files changed, 23 insertions(+), 52 deletions(-) diff --git a/Editor/AvatarTagComponentEditorBase.cs b/Editor/AvatarTagComponentEditorBase.cs index 5543f17ec..e1aa52391 100644 --- a/Editor/AvatarTagComponentEditorBase.cs +++ b/Editor/AvatarTagComponentEditorBase.cs @@ -17,15 +17,13 @@ public sealed override void OnInspectorGUI() OnInspectorGUIInner(); } - protected abstract string Description { get; } + protected virtual string Description => null; protected abstract void OnInspectorGUIInner(); } [CustomEditor(typeof(AvatarTagComponent), true)] class DefaultAvatarTagComponentEditor : AvatarTagComponentEditorBase { - protected override string Description => null; - protected override void OnInspectorGUIInner() { serializedObject.UpdateIfRequiredOrScript(); diff --git a/Editor/ClearEndpointPositionEditor.cs b/Editor/ClearEndpointPositionEditor.cs index d4da24a5d..69d6c47dd 100644 --- a/Editor/ClearEndpointPositionEditor.cs +++ b/Editor/ClearEndpointPositionEditor.cs @@ -7,15 +7,12 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(ClearEndpointPosition))] - internal class ClearEndpointPositionEditor : Editor + internal class ClearEndpointPositionEditor : AvatarTagComponentEditorBase { - private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); - public override void OnInspectorGUI() - { - EditorGUILayout.HelpBox(CL4EE.Tr("ClearEndpointPosition:description"), MessageType.None); - - _saveVersion.Draw(serializedObject); + protected override string Description => CL4EE.Tr("ClearEndpointPosition:description"); + protected override void OnInspectorGUIInner() + { if (GUILayout.Button(CL4EE.Tr("ClearEndpointPosition:button:Apply and Remove Component"))) { ClearEndpointPositionProcessor.Process(((Component)target).GetComponent()); diff --git a/Editor/FreezeBlendShapeEditor.cs b/Editor/FreezeBlendShapeEditor.cs index 2d5230a27..c5f23886f 100644 --- a/Editor/FreezeBlendShapeEditor.cs +++ b/Editor/FreezeBlendShapeEditor.cs @@ -5,9 +5,8 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(FreezeBlendShape))] - public class FreezeBlendShapeEditor : Editor + class FreezeBlendShapeEditor : AvatarTagComponentEditorBase { - private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); private PrefabSafeSet.EditorUtil _shapeKeysSet; private void OnEnable() @@ -20,10 +19,8 @@ private void OnEnable() (x, v) => x.stringValue = v); } - public override void OnInspectorGUI() + protected override void OnInspectorGUIInner() { - _saveVersion.Draw(serializedObject); - var component = (FreezeBlendShape)target; var shapes = EditSkinnedMeshComponentUtil.GetBlendShapes(component.GetComponent(), component); diff --git a/Editor/MakeChildrenEditor.cs b/Editor/MakeChildrenEditor.cs index d801f3411..4a507247b 100644 --- a/Editor/MakeChildrenEditor.cs +++ b/Editor/MakeChildrenEditor.cs @@ -6,9 +6,9 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(MakeChildren))] [CanEditMultipleObjects] - internal class MakeChildrenEditor : Editor + internal class MakeChildrenEditor : AvatarTagComponentEditorBase { - private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); + protected override string Description => CL4EE.Tr("MakeChildren:description"); private SerializedProperty _children; private void OnEnable() @@ -16,10 +16,8 @@ private void OnEnable() _children = serializedObject.FindProperty(nameof(MakeChildren.children)); } - public override void OnInspectorGUI() + protected override void OnInspectorGUIInner() { - EditorGUILayout.HelpBox(CL4EE.Tr("MakeChildren:description"), MessageType.None); - _saveVersion.Draw(serializedObject); EditorGUILayout.PropertyField(_children); serializedObject.ApplyModifiedProperties(); } diff --git a/Editor/MergeBoneEditor.cs b/Editor/MergeBoneEditor.cs index 7208b3e5b..e47bd3065 100644 --- a/Editor/MergeBoneEditor.cs +++ b/Editor/MergeBoneEditor.cs @@ -4,13 +4,12 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(MergeBone))] - public class MergeBoneEditor : Editor + class MergeBoneEditor : AvatarTagComponentEditorBase { - private SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); - public override void OnInspectorGUI() + protected override string Description => CL4EE.Tr("MergeBone:description"); + + protected override void OnInspectorGUIInner() { - EditorGUILayout.HelpBox(CL4EE.Tr("MergeBone:description"), MessageType.None); - _saveVersion.Draw(serializedObject); } } } diff --git a/Editor/MergePhysBoneEditor.cs b/Editor/MergePhysBoneEditor.cs index ee9c05097..fbb0da521 100644 --- a/Editor/MergePhysBoneEditor.cs +++ b/Editor/MergePhysBoneEditor.cs @@ -8,7 +8,7 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(MergePhysBone))] - internal class MergePhysBoneEditor : Editor + internal class MergePhysBoneEditor : AvatarTagComponentEditorBase { private static class Style { @@ -25,7 +25,6 @@ private static class Style }; } - private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); private SerializedProperty _mergedComponentProp; private SerializedProperty _rootTransformProp; private SerializedProperty _forcesProp; @@ -80,9 +79,8 @@ private void OnEnable() (x, v) => x.objectReferenceValue = v); } - public override void OnInspectorGUI() + protected override void OnInspectorGUIInner() { - _saveVersion.Draw(serializedObject); EditorGUI.BeginDisabledGroup(_mergedComponentProp.objectReferenceValue != null); EditorGUILayout.PropertyField(_mergedComponentProp); EditorGUI.EndDisabledGroup(); diff --git a/Editor/MergeSkinnedMeshEditor.cs b/Editor/MergeSkinnedMeshEditor.cs index e6b12866c..f5dabe68a 100644 --- a/Editor/MergeSkinnedMeshEditor.cs +++ b/Editor/MergeSkinnedMeshEditor.cs @@ -7,7 +7,7 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(MergeSkinnedMesh))] - internal class MergeSkinnedMeshEditor : Editor + internal class MergeSkinnedMeshEditor : AvatarTagComponentEditorBase { private static class Style { @@ -24,7 +24,6 @@ private static class Style }; } - private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); SerializedProperty _renderersSetProp; SerializedProperty _staticRenderersSetProp; SerializedProperty _removeEmptyRendererObjectProp; @@ -43,9 +42,8 @@ private void OnEnable() (x, v) => x.objectReferenceValue = v); } - public override void OnInspectorGUI() + protected override void OnInspectorGUIInner() { - _saveVersion.Draw(serializedObject); if (((MergeSkinnedMesh)target).GetComponent().sharedMesh) { EditorGUILayout.HelpBox(CL4EE.Tr("MergeSkinnedMesh:warning:MeshIsNotNone"), MessageType.Warning); diff --git a/Editor/MergeToonLitMaterialEditor.cs b/Editor/MergeToonLitMaterialEditor.cs index 2706e66f9..4f21652f1 100644 --- a/Editor/MergeToonLitMaterialEditor.cs +++ b/Editor/MergeToonLitMaterialEditor.cs @@ -10,9 +10,9 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(MergeToonLitMaterial))] - internal class MergeToonLitMaterialEditor : Editor + internal class MergeToonLitMaterialEditor : AvatarTagComponentEditorBase { - private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); + protected override string Description => CL4EE.Tr("MergeToonLitMaterial:description"); private Material[] _upstreamMaterials; private (Material mat, int index)[] _materials; @@ -95,12 +95,8 @@ private static void DrawList( } - public override void OnInspectorGUI() + protected override void OnInspectorGUIInner() { - EditorGUILayout.HelpBox(CL4EE.Tr("MergeToonLitMaterial:description"), MessageType.None); - - _saveVersion.Draw(serializedObject); - EditorGUI.BeginChangeCheck(); var component = (MergeToonLitMaterial)target; diff --git a/Editor/RemoveMeshInBoxEditor.cs b/Editor/RemoveMeshInBoxEditor.cs index 81cf4f141..34a2772dc 100644 --- a/Editor/RemoveMeshInBoxEditor.cs +++ b/Editor/RemoveMeshInBoxEditor.cs @@ -6,11 +6,9 @@ namespace Anatawa12.AvatarOptimizer { [CustomEditor(typeof(RemoveMeshInBox))] - internal class RemoveMeshInBoxEditor : Editor + internal class RemoveMeshInBoxEditor : AvatarTagComponentEditorBase { - private readonly SaveVersionDrawer _saveVersion = new SaveVersionDrawer(); private ListEditor _boxList; - private int _editingBox = -1; private void OnEnable() { @@ -18,16 +16,8 @@ private void OnEnable() _boxList = new ListEditor(serializedObject.FindProperty("boxList"), nestCount); } - public override void OnInspectorGUI() + protected override void OnInspectorGUIInner() { - if (targets.Length != 1) - { - base.OnInspectorGUI(); - return; - } - - _saveVersion.Draw(serializedObject); - var rect = EditorGUILayout.GetControlRect(true, _boxList.GetPropertyHeight()); _boxList.OnGUI(rect); From f3c68a054d8dc051cb046e751f5097097492a569 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 21:00:49 +0900 Subject: [PATCH 14/15] chore: add language picker --- Editor/AvatarTagComponentEditorBase.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Editor/AvatarTagComponentEditorBase.cs b/Editor/AvatarTagComponentEditorBase.cs index e1aa52391..6977f5e43 100644 --- a/Editor/AvatarTagComponentEditorBase.cs +++ b/Editor/AvatarTagComponentEditorBase.cs @@ -1,3 +1,4 @@ +using CustomLocalization4EditorExtension; using UnityEditor; namespace Anatawa12.AvatarOptimizer @@ -8,6 +9,8 @@ abstract class AvatarTagComponentEditorBase : Editor public sealed override void OnInspectorGUI() { + CL4EE.DrawLanguagePicker(); + var description = Description; if (!string.IsNullOrEmpty(description)) EditorGUILayout.HelpBox(description, MessageType.None); From f5ab1b23ab79a9f4634ed72c51d561efce7d93c0 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 26 Mar 2023 21:09:57 +0900 Subject: [PATCH 15/15] docs(changelog): add Internationalization support --- CHANGELOG-PRERELEASE.md | 4 ++++ CHANGELOG.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 63c764b29..76bff2759 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog]. ## [Unreleased] ### Added +- Internationalization support `#77` + - This adds way to translate editor elements. + - However, no other language translation than English is not added yet. + - Please feel free to make PullRequest if you can maintain the translation. ### Changed diff --git a/CHANGELOG.md b/CHANGELOG.md index 86d0dd1f4..78de2106a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog]. ## [Unreleased] ### Added +- Internationalization support `#77` + - This adds way to translate editor elements. + - However, no other language translation than English is not added yet. + - Please feel free to make PullRequest if you can maintain the translation. ### Changed