diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4376f4f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/.* export-ignore +/Documentation~ export-ignore +/Tests export-ignore +/Tests.meta export-ignore + + diff --git a/.yamato/upm-ci-SpringBone.yml b/.yamato/upm-ci-SpringBone.yml new file mode 100644 index 0000000..46549dd --- /dev/null +++ b/.yamato/upm-ci-SpringBone.yml @@ -0,0 +1,77 @@ +yamato_name: SpringBone +test_editors: + - version: 2019.4 + - version: 2020.3 + - version: 2021.1 +test_platforms: + - name: win + type: Unity::VM + image: package-ci/win10:stable + flavor: b1.large + - name: mac + type: Unity::VM::osx + image: package-ci/mac:stable + flavor: m1.mac +--- +pack: + name: Pack {{ yamato_name }} + agent: + type: Unity::VM + image: package-ci/win10:stable + flavor: b1.large + commands: + - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + - upm-ci package pack + artifacts: + {{ yamato_name }}_pack_artifacts: + paths: + - "upm-ci~/**/*" + +{% for editor in test_editors %} +{% for platform in test_platforms %} +test_{{ platform.name }}_{{ editor.version }}: + name : Test {{ yamato_name }} using {{ editor.version }} on {{ platform.name }} + agent: + type: {{ platform.type }} + image: {{ platform.image }} + flavor: {{ platform.flavor}} + commands: + - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + - upm-ci package test --unity-version {{ editor.version }} + triggers: + branches: + only: + - "/.*/" + artifacts: + {{ yamato_name }}_test_results: + paths: + - "upm-ci~/test-results/**/*" + dependencies: + - .yamato/upm-ci-{{ yamato_name }}.yml#pack +{% endfor %} +{% endfor %} + +publish: + name: Publish {{ yamato_name }} to Internal Registry + agent: + type: Unity::VM + image: package-ci/win10:stable + flavor: b1.large + commands: + - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + - upm-ci package publish + triggers: + tags: + only: + - /^(r|R)(c|C)-\d+\.\d+\.\d+(-preview(\.\d+)?)?$/ + artifacts: + {{ yamato_name }}_publish_artifacts: + paths: + - "upm-ci~/packages/*.tgz" + dependencies: + - .yamato/upm-ci-{{ yamato_name }}.yml#pack + {% for editor in test_editors %} + {% for platform in test_platforms %} + - .yamato/upm-ci-{{ yamato_name }}.yml#test_{{ platform.name }}_{{ editor.version }} + {% endfor %} + {% endfor %} diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb106e..e1f5565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,26 @@ # Changelog All notable changes to this package will be documented in this file. - The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.2.2] - 2021-10-15 +### Added +- *conditional* localization attribute definition. Fixes editor script import on 2020.3 while preserving functions on 2019.4. + +### Fixed +- Gizmos are not shown when scaled. +- Null pointer exception when SpringBonePivot is selected on the hierarchy. + + +## [1.2.1-preview] - 2020-12-10 +### Fixed +- Assembly issue during buid. + +## [1.2.0-preview] - 2020-12-02 +### Changed +- Set default language to English. Except Inspector GUI yet. +- Minimum supported Unity version is 2019.4 + ## [1.1.0] - 2019-10-31 *This is the first version of UnityChan Spring Bone in the package form.* diff --git a/Documentation~/index.md b/Documentation~/index.md new file mode 100644 index 0000000..1056e51 --- /dev/null +++ b/Documentation~/index.md @@ -0,0 +1,12 @@ +>>> +**_Springbone Documentation_** + +Work in progress + +## Document revision history +>>> + +|Date|Reason| +|---|---| +|Oct 16, 2021|Document created. Matches package version 1.2.2-preview| +>>> diff --git a/Editor/AssmblyInfo.cs b/Editor/AssmblyInfo.cs new file mode 100644 index 0000000..955ca8c --- /dev/null +++ b/Editor/AssmblyInfo.cs @@ -0,0 +1,7 @@ +#if UNITY_2020_1_OR_NEWER +using Localization = UnityEditor.LocalizationAttribute; +#else +using Localization = UnityEditor.Localization.Editor.LocalizationAttribute; +#endif + +[assembly: Localization] \ No newline at end of file diff --git a/Editor/AssmblyInfo.cs.meta b/Editor/AssmblyInfo.cs.meta new file mode 100644 index 0000000..1c02fdf --- /dev/null +++ b/Editor/AssmblyInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2ad4ab0d6f72042059f8f8c7daeb9f75 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/AutoSpringBoneSetup.cs b/Editor/AutoSpringBoneSetup.cs index 7a75aa5..2f0ca90 100755 --- a/Editor/AutoSpringBoneSetup.cs +++ b/Editor/AutoSpringBoneSetup.cs @@ -3,6 +3,11 @@ using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { diff --git a/Editor/GUI/Inspectors/SpringBonePivotInspector.cs b/Editor/GUI/Inspectors/SpringBonePivotInspector.cs index 8f8cc7d..42b91e1 100755 --- a/Editor/GUI/Inspectors/SpringBonePivotInspector.cs +++ b/Editor/GUI/Inspectors/SpringBonePivotInspector.cs @@ -13,6 +13,7 @@ public override void OnInspectorGUI() { InitializeData(); + SpringBoneGUIStyles.ReacquireStyles(); if (GUILayout.Button("ボーンを選択", SpringBoneGUIStyles.ButtonStyle)) { Selection.objects = bones.Select(bone => bone.gameObject).ToArray(); diff --git a/Editor/GUI/Windows/LoadSpringBoneSetupWindow.cs b/Editor/GUI/Windows/LoadSpringBoneSetupWindow.cs index 6346254..d2a754e 100755 --- a/Editor/GUI/Windows/LoadSpringBoneSetupWindow.cs +++ b/Editor/GUI/Windows/LoadSpringBoneSetupWindow.cs @@ -1,15 +1,50 @@ using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public class LoadSpringBoneSetupWindow : EditorWindow { + private static class Styles + { + public static readonly string editorWindowTitle = Localization.Tr("Load spring bone setup"); + public static readonly string stopPlayModeMessage = Localization.Tr("Do not setup in Play Mode"); + public static readonly string selectObjectRootsMessage = Localization.Tr("Select parent object of the spring bone"); + public static readonly string resultFormat = Localization.Tr("Set up complete:{0}\nNumber of bones: {1} Number of colliders: {2}"); + public static readonly string csvFile = Localization.Tr("CSV File"); + public static readonly string textFile = Localization.Tr("Text File"); + public static readonly string loadSpringBoneSetup = Localization.Tr("Load spring bone setup"); + public static readonly string errorFormat = Localization.Tr( + "SpringBone setup failed.\n" + + "Souce data may contain errors,\n" + + "or the data don't match the character.\n" + + "Please refer console logs for further info.\n" + + "\n" + + "Character: {0}\n" + + "\n" + + "Path: {1}"); + + public static readonly string springBoneSetup = Localization.Tr("SpringBone Setup"); + public static readonly string springBoneSetupFailedFormat = Localization.Tr("SpringBone Setup failed:{0}\nPath:{1}"); + public static readonly string labelSpringBoneRoot = Localization.Tr("SpringBone Root"); + + public static readonly GUIContent labelLoadingConfig = new GUIContent(Localization.Tr("Loading Configuration")); + public static readonly GUIContent labelSpringBone = new GUIContent(Localization.Tr("SpringBone")); + public static readonly GUIContent labelCollider = new GUIContent(Localization.Tr("Collider")); + + public static readonly GUIContent labelSelectFromRoot = new GUIContent(Localization.Tr("Get root from selection")); + public static readonly GUIContent labelSetupLoadCSV = new GUIContent(Localization.Tr("Set up from CSV file")); + } + public static void ShowWindow() { - var editorWindow = GetWindow( - "スプリングボーンセットアップを読み込む"); + var editorWindow = GetWindow(Styles.editorWindowTitle); if (editorWindow != null) { editorWindow.SelectObjectsFromSelection(); @@ -35,8 +70,6 @@ ref int yPos // private - private const string StopPlayModeMessage = "再生モードでセットアップしないでください。"; - private const string SelectObjectRootsMessage = "スプリングボーンの親オブジェクトを指定してください。"; private const int UIRowHeight = 24; private const int UISpacing = 8; private const int LabelWidth = 200; @@ -74,11 +107,11 @@ private void ShowImportSettingsUI(ref Rect uiRect) importSettings = new DynamicsSetup.ImportSettings(); } - GUI.Label(uiRect, "読み込み設定", SpringBoneGUIStyles.HeaderLabelStyle); + GUI.Label(uiRect, Styles.labelLoadingConfig, SpringBoneGUIStyles.HeaderLabelStyle); uiRect.y += uiRect.height; - importSettings.ImportSpringBones = GUI.Toggle(uiRect, importSettings.ImportSpringBones, "スプリングボーン", SpringBoneGUIStyles.ToggleStyle); + importSettings.ImportSpringBones = GUI.Toggle(uiRect, importSettings.ImportSpringBones, Styles.labelSpringBone, SpringBoneGUIStyles.ToggleStyle); uiRect.y += uiRect.height; - importSettings.ImportCollision = GUI.Toggle(uiRect, importSettings.ImportCollision, "コライダー", SpringBoneGUIStyles.ToggleStyle); + importSettings.ImportCollision = GUI.Toggle(uiRect, importSettings.ImportCollision, Styles.labelCollider, SpringBoneGUIStyles.ToggleStyle); uiRect.y += uiRect.height; } @@ -90,9 +123,9 @@ private void OnGUI() var uiWidth = (int)position.width - UISpacing * 2; var yPos = UISpacing; - springBoneRoot = DoObjectPicker("スプリングボーンのルート", springBoneRoot, uiWidth, UIRowHeight, ref yPos); + springBoneRoot = DoObjectPicker(Styles.labelSpringBoneRoot, springBoneRoot, uiWidth, UIRowHeight, ref yPos); var buttonRect = new Rect(UISpacing, yPos, uiWidth, ButtonHeight); - if (GUI.Button(buttonRect, "選択からルートを取得", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(buttonRect, Styles.labelSelectFromRoot, SpringBoneGUIStyles.ButtonStyle)) { SelectObjectsFromSelection(); } @@ -104,7 +137,7 @@ private void OnGUI() string errorMessage; if (IsOkayToSetup(out errorMessage)) { - if (GUI.Button(buttonRect, "CSVを読み込んでセットアップ", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(buttonRect, Styles.labelSetupLoadCSV, SpringBoneGUIStyles.ButtonStyle)) { BrowseAndLoadSpringSetup(); } @@ -122,13 +155,13 @@ private bool IsOkayToSetup(out string errorMessage) errorMessage = ""; if (EditorApplication.isPlaying) { - errorMessage = StopPlayModeMessage; + errorMessage = Styles.stopPlayModeMessage; return false; } if (springBoneRoot == null) { - errorMessage = SelectObjectRootsMessage; + errorMessage = Styles.selectObjectRootsMessage; return false; } return true; @@ -169,11 +202,10 @@ public void Perform() setup.Build(); AssetDatabase.Refresh(); - const string ResultFormat = "セットアップ完了: {0}\nボーン数: {1} コライダー数: {2}"; var boneCount = springBoneRoot.GetComponentsInChildren(true).Length; var colliderCount = SpringColliderSetup.GetColliderTypes() .Sum(type => springBoneRoot.GetComponentsInChildren(type, true).Length); - var resultMessage = string.Format(ResultFormat, path, boneCount, colliderCount); + var resultMessage = string.Format(Styles.resultFormat, path, boneCount, colliderCount); Debug.Log(resultMessage); } @@ -184,8 +216,7 @@ public void Perform() private void BrowseAndLoadSpringSetup() { - string checkErrorMessage; - if (!IsOkayToSetup(out checkErrorMessage)) + if (!IsOkayToSetup(out var checkErrorMessage)) { Debug.LogError(checkErrorMessage); return; @@ -193,9 +224,9 @@ private void BrowseAndLoadSpringSetup() // var initialPath = ""; var initialDirectory = ""; // System.IO.Path.GetDirectoryName(initialPath); - var fileFilters = new string[] { "CSVファイル", "csv", "テキストファイル", "txt" }; + var fileFilters = new string[] { Styles.csvFile, "csv", Styles.textFile, "txt" }; var path = EditorUtility.OpenFilePanelWithFilters( - "スプリングボーンセットアップを読み込む", initialDirectory, fileFilters); + Styles.loadSpringBoneSetup, initialDirectory, fileFilters); if (path.Length == 0) { return; } var sourceText = FileUtil.ReadAllText(path); @@ -216,16 +247,10 @@ private void BrowseAndLoadSpringSetup() } else { - const string ErrorFormat = - "スプリングボーンセットアップが失敗しました。\n" - + "元データにエラーがあるか、もしくは\n" - + "キャラクターにデータが一致しません。\n" - + "詳しくはConsoleのログをご覧下さい。\n\n" - + "キャラクター: {0}\n\n" - + "パス: {1}"; - var resultErrorMessage = string.Format(ErrorFormat, springBoneRoot.name, path); - EditorUtility.DisplayDialog("スプリングボーンセットアップ", resultErrorMessage, "OK"); - Debug.LogError("スプリングボーンセットアップ失敗: " + springBoneRoot.name + "\n" + path); + var resultErrorMessage = string.Format(Styles.errorFormat, springBoneRoot.name, path); + EditorUtility.DisplayDialog(Styles.springBoneSetup, resultErrorMessage, "OK"); + Debug.LogFormat(LogType.Error, LogOption.None, springBoneRoot, + Styles.springBoneSetupFailedFormat, springBoneRoot.name, path); } Close(); } diff --git a/Editor/GUI/Windows/MirrorSpringBoneWindow.cs b/Editor/GUI/Windows/MirrorSpringBoneWindow.cs index 0eb7e7f..6781f9e 100755 --- a/Editor/GUI/Windows/MirrorSpringBoneWindow.cs +++ b/Editor/GUI/Windows/MirrorSpringBoneWindow.cs @@ -3,14 +3,35 @@ using UnityEditor; using UnityEngine; using Unity.Animations.SpringBones.GameObjectExtensions; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public class MirrorSpringBoneWindow : EditorWindow { + private static class Styles + { + public static readonly string editorWindowTitle = Localization.Tr("SpringBone Mirror"); + + public static readonly GUIContent labelDoMirror = new GUIContent(Localization.Tr("Do Mirror")); + public static readonly GUIContent labelGetFromSelection = new GUIContent(Localization.Tr("Get from selection")); + + public static readonly GUIContent labelSelectAllCopyDst = new GUIContent(Localization.Tr("Select all copy destination")); + public static readonly GUIContent labelSelectAllCopySrc = new GUIContent(Localization.Tr("Select all copy source")); + public static readonly GUIContent labelSelectAll = new GUIContent(Localization.Tr("Select All")); + public static readonly GUIContent labelConfigXbZero = new GUIContent(Localization.Tr("Set bone where X > 0")); + public static readonly GUIContent labelConfigXlZero = new GUIContent(Localization.Tr("Set bone where X < 0")); + public static readonly GUIContent labelSrc = new GUIContent(Localization.Tr("Source")); + public static readonly GUIContent labelDst = new GUIContent(Localization.Tr("→ Destination")); + } + public static void ShowWindow() { - var window = GetWindow("SpringBoneミラー"); + var window = GetWindow(Styles.editorWindowTitle); window.Show(); window.OnShow(); } @@ -57,7 +78,7 @@ private void OnGUI() uiRect = ShowUtilityButtons(uiRect); uiRect = ShowBoneList(uiRect); - if (GUI.Button(uiRect, "ミラーを行う", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(uiRect, Styles.labelDoMirror, SpringBoneGUIStyles.ButtonStyle)) { PerformMirror(); } @@ -66,7 +87,7 @@ private void OnGUI() private Rect ShowUtilityButtons(Rect uiRect) { var buttonOffset = uiRect.height + Spacing; - if (GUI.Button(uiRect, "選択から取得", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(uiRect, Styles.labelGetFromSelection, SpringBoneGUIStyles.ButtonStyle)) { AcquireBonesFromSelection(); } @@ -74,12 +95,12 @@ private Rect ShowUtilityButtons(Rect uiRect) var halfRectWidth = 0.5f * (uiRect.width - Spacing); var halfButtonRect = new Rect(uiRect.x, uiRect.y, halfRectWidth, uiRect.height); - if (GUI.Button(halfButtonRect, "X < 0のボーンを元に設定", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(halfButtonRect, Styles.labelConfigXlZero, SpringBoneGUIStyles.ButtonStyle)) { AcquireSourceBonesOnSideOfAxis(true); } halfButtonRect.x += halfRectWidth + Spacing; - if (GUI.Button(halfButtonRect, "X > 0のボーンを元に設定", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(halfButtonRect, Styles.labelConfigXbZero, SpringBoneGUIStyles.ButtonStyle)) { AcquireSourceBonesOnSideOfAxis(false); } @@ -87,20 +108,20 @@ private Rect ShowUtilityButtons(Rect uiRect) halfButtonRect.x = uiRect.x; halfButtonRect.y = uiRect.y; - if (GUI.Button(halfButtonRect, "コピー元を全選択", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(halfButtonRect, Styles.labelSelectAllCopySrc, SpringBoneGUIStyles.ButtonStyle)) { var sourceBones = boneEntries.Select(entry => entry.sourceBone).Where(bone => bone != null); if (sourceBones.Any()) { Selection.objects = sourceBones.Select(bone => bone.gameObject).ToArray(); } } halfButtonRect.x += halfRectWidth + Spacing; - if (GUI.Button(halfButtonRect, "コピー先を全選択", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(halfButtonRect, Styles.labelSelectAllCopyDst, SpringBoneGUIStyles.ButtonStyle)) { var targetBones = boneEntries.Select(entry => entry.targetBone).Where(bone => bone != null); if (targetBones.Any()) { Selection.objects = targetBones.Select(bone => bone.gameObject).ToArray(); } } uiRect.y += buttonOffset; - if (GUI.Button(uiRect, "全選択", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(uiRect, Styles.labelSelectAll, SpringBoneGUIStyles.ButtonStyle)) { var bonesToSelect = new List(); bonesToSelect.AddRange(boneEntries.Select(entry => entry.sourceBone).Where(bone => bone != null)); @@ -117,9 +138,9 @@ private Rect ShowBoneList(Rect uiRect) var listBoxBottom = position.height - (Spacing * 2f + RowHeight); var headerRowRect = new Rect(uiRect.x, uiRect.y, uiRect.width * 0.5f, uiRect.height); - GUI.Label(headerRowRect, "元", SpringBoneGUIStyles.LabelStyle); + GUI.Label(headerRowRect, Styles.labelSrc, SpringBoneGUIStyles.LabelStyle); headerRowRect.x += headerRowRect.width; - GUI.Label(headerRowRect, "→ 先", SpringBoneGUIStyles.LabelStyle); + GUI.Label(headerRowRect, Styles.labelDst, SpringBoneGUIStyles.LabelStyle); uiRect.y += uiRect.height; const float ScrollbarWidth = 20f; diff --git a/Editor/GUI/Windows/SaveSpringBoneSetupWindow.cs b/Editor/GUI/Windows/SaveSpringBoneSetupWindow.cs index 5df218c..5ab245e 100755 --- a/Editor/GUI/Windows/SaveSpringBoneSetupWindow.cs +++ b/Editor/GUI/Windows/SaveSpringBoneSetupWindow.cs @@ -1,15 +1,38 @@ -using System.Linq; +using System; +using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public class SaveSpringBoneSetupWindow : EditorWindow { + private static class Styles + { + public static readonly string editorWindowTitle = Localization.Tr("Save SpringBone Setup"); + public static readonly string textSpringBoneRoot = Localization.Tr("SpringBone Root"); + public static readonly string textSaveSpringBoneSetup = Localization.Tr("Save SpringBone Setup"); + public static readonly string textSaveSpringBone = Localization.Tr("Save SpringBone"); + public static readonly string textFileOverwriteFormat = Localization.Tr("File already exists. Overwrite?:{0}\n\n"); + public static readonly string textOverwrite = Localization.Tr("Overwrite"); + public static readonly string textSavedFormat = Localization.Tr("Saved.: {0}"); + public static readonly string textCancel = Localization.Tr("Cancel"); + + public static readonly GUIContent labelExportSetting = new GUIContent(Localization.Tr("Export Setting")); + public static readonly GUIContent labelSpringBone = new GUIContent(Localization.Tr("SpringBone")); + public static readonly GUIContent labelCollider = new GUIContent(Localization.Tr("Collider")); + public static readonly GUIContent labelGetRootFromSelection = new GUIContent(Localization.Tr("Get root from selection")); + public static readonly GUIContent labelSaveToCSV = new GUIContent(Localization.Tr("Save to CSV")); + } + public static void ShowWindow() { - var editorWindow = GetWindow( - "スプリングボーンセットアップを保存"); + var editorWindow = GetWindow(Styles.editorWindowTitle); if (editorWindow != null) { editorWindow.SelectObjectsFromSelection(); @@ -52,11 +75,11 @@ private void ShowExportSettingsUI(ref Rect uiRect) exportSettings = new SpringBoneSerialization.ExportSettings(); } - GUI.Label(uiRect, "書き出し設定", SpringBoneGUIStyles.HeaderLabelStyle); + GUI.Label(uiRect, Styles.labelExportSetting, SpringBoneGUIStyles.HeaderLabelStyle); uiRect.y += uiRect.height; - exportSettings.ExportSpringBones = GUI.Toggle(uiRect, exportSettings.ExportSpringBones, "スプリングボーン", SpringBoneGUIStyles.ToggleStyle); + exportSettings.ExportSpringBones = GUI.Toggle(uiRect, exportSettings.ExportSpringBones, Styles.labelSpringBone, SpringBoneGUIStyles.ToggleStyle); uiRect.y += uiRect.height; - exportSettings.ExportCollision = GUI.Toggle(uiRect, exportSettings.ExportCollision, "コライダー", SpringBoneGUIStyles.ToggleStyle); + exportSettings.ExportCollision = GUI.Toggle(uiRect, exportSettings.ExportCollision,Styles.labelCollider, SpringBoneGUIStyles.ToggleStyle); uiRect.y += uiRect.height; } @@ -72,9 +95,9 @@ private void OnGUI() var yPos = UISpacing; springBoneRoot = LoadSpringBoneSetupWindow.DoObjectPicker( - "スプリングボーンのルート", springBoneRoot, uiWidth, UIRowHeight, ref yPos); + Styles.textSpringBoneRoot, springBoneRoot, uiWidth, UIRowHeight, ref yPos); var buttonRect = new Rect(UISpacing, yPos, uiWidth, ButtonHeight); - if (GUI.Button(buttonRect, "選択からルートを取得", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(buttonRect, Styles.labelGetRootFromSelection, SpringBoneGUIStyles.ButtonStyle)) { SelectObjectsFromSelection(); } @@ -84,7 +107,7 @@ private void OnGUI() ShowExportSettingsUI(ref buttonRect); if (springBoneRoot != null) { - if (GUI.Button(buttonRect, "CSVを保存", SpringBoneGUIStyles.ButtonStyle)) + if (GUI.Button(buttonRect, Styles.labelSaveToCSV, SpringBoneGUIStyles.ButtonStyle)) { BrowseAndSaveSpringSetup(); } @@ -98,13 +121,14 @@ private void BrowseAndSaveSpringSetup() var initialFileName = springBoneRoot.name + "_Dynamics.csv"; var path = EditorUtility.SaveFilePanel( - "スプリングボーンセットアップを保存", "", initialFileName, "csv"); + Styles.textSaveSpringBoneSetup, "", initialFileName, "csv"); if (path.Length == 0) { return; } if (System.IO.File.Exists(path)) { - var overwriteMessage = "ファイルは既に存在します。上書きしますか?\n\n" + path; - if (!EditorUtility.DisplayDialog("スプリングボーン保存", overwriteMessage, "上書き", "キャンセル")) + var overwriteMessage = string.Format(Styles.textFileOverwriteFormat, path); + if (!EditorUtility.DisplayDialog(Styles.textSaveSpringBone, overwriteMessage, Styles.textOverwrite, + Styles.textCancel)) { return; } @@ -114,7 +138,7 @@ private void BrowseAndSaveSpringSetup() if (FileUtil.WriteAllText(path, sourceText)) { AssetDatabase.Refresh(); - Debug.Log("保存しました: " + path); + Debug.LogFormat(Styles.textSavedFormat, path); } } } diff --git a/Editor/GUI/Windows/SpringBoneSetupErrorWindow.cs b/Editor/GUI/Windows/SpringBoneSetupErrorWindow.cs index c4762fc..38775a9 100755 --- a/Editor/GUI/Windows/SpringBoneSetupErrorWindow.cs +++ b/Editor/GUI/Windows/SpringBoneSetupErrorWindow.cs @@ -2,11 +2,29 @@ using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public class SpringBoneSetupErrorWindow : EditorWindow { + private static class Styles + { + public static readonly string editorWindowTitle = Localization.Tr("Setup Dynamics"); + + public static readonly GUIContent labelAskDynamicError = new GUIContent(Localization.Tr("There are errors in dynamics setup. Do you want to create only ones without error(s)?")); + public static readonly GUIContent labelSpringBoneRoot = new GUIContent(Localization.Tr("SpringBone Root")); + public static readonly GUIContent labelColliderRoot = new GUIContent(Localization.Tr("Collider Root")); + public static readonly GUIContent labelPath = new GUIContent(Localization.Tr("Path")); + public static readonly GUIContent labelCreate = new GUIContent(Localization.Tr("Create")); + public static readonly GUIContent labelCancel = new GUIContent(Localization.Tr("Cancel")); + public static readonly GUIContent labelError = new GUIContent(Localization.Tr("Error")); + } + public interface IConfirmAction { void Perform(); @@ -21,7 +39,7 @@ public static void ShowWindow IConfirmAction onConfirm ) { - var window = GetWindow("ダイナミクスセットアップ"); + var window = GetWindow(Styles.editorWindowTitle); window.springBoneRoot = springBoneRoot; window.colliderRoot = colliderRoot; window.filePath = path; @@ -41,23 +59,23 @@ IConfirmAction onConfirm private void OnGUI() { EditorGUILayout.Space(); - GUILayout.Label("ダイナミクスセットアップに一部エラーが出ているものがあります。正常なものだけ作成しますか?"); + GUILayout.Label(Styles.labelAskDynamicError); EditorGUILayout.Space(); - EditorGUILayout.ObjectField("スプリングボーンのルート", springBoneRoot, typeof(GameObject), true); - EditorGUILayout.ObjectField("コライダーのルート", colliderRoot, typeof(GameObject), true); - EditorGUILayout.TextField("パス", filePath); + EditorGUILayout.ObjectField(Styles.labelSpringBoneRoot, springBoneRoot, typeof(GameObject), true); + EditorGUILayout.ObjectField(Styles.labelColliderRoot, colliderRoot, typeof(GameObject), true); + EditorGUILayout.TextField(Styles.labelPath, filePath); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); - if (GUILayout.Button("作成")) + if (GUILayout.Button(Styles.labelCreate)) { onConfirmAction.Perform(); Close(); } - if (GUILayout.Button("キャンセル")) { Close(); } + if (GUILayout.Button(Styles.labelCancel)) { Close(); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); - GUILayout.Label("エラー"); + GUILayout.Label(Styles.labelError); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true); foreach (var error in errors) { diff --git a/Editor/GUI/Windows/SpringBoneWindow.cs b/Editor/GUI/Windows/SpringBoneWindow.cs index 90ba895..14ac210 100755 --- a/Editor/GUI/Windows/SpringBoneWindow.cs +++ b/Editor/GUI/Windows/SpringBoneWindow.cs @@ -1,15 +1,58 @@ using System.Linq; +using Unity.Collections; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public class SpringBoneWindow : EditorWindow { - [MenuItem("UTJ/スプリングボーン窓")] + private static class Styles + { + public static readonly string editorWindowTitle = Localization.Tr("SpringBone"); + + public static readonly string logIconLoadFailedFormat = Localization.Tr("Icon load failed:\nPath:{0}"); + public static readonly string logIconDirNotFound = Localization.Tr("SpringBoneWindow icon directory not found"); + + public static readonly string labelDynamicCSV = Localization.Tr("Dynamics CSV"); + public static readonly string labelLoad = Localization.Tr("Load"); + public static readonly string labelSave = Localization.Tr("Save"); + public static readonly string labelSpringBone = (Localization.Tr("SpringBone")); + public static readonly string labelSpringBoneAdd = (Localization.Tr("Add\nSpringBone")); + public static readonly string labelCreateOrigin = (Localization.Tr("Create Origin")); + public static readonly string labelCreateManager = (Localization.Tr("Create or Update Manager")); + public static readonly string labelMirrorBone = (Localization.Tr("Mirror SpringBones")); + public static readonly string labelSelectOneAndChild = (Localization.Tr("Select this and child bones")); + public static readonly string labelDeleteBone = (Localization.Tr("Delete SpringBone")); + public static readonly string labelDeleteBoneAndManager = (Localization.Tr("Delete Managers and Bones of Selection and Children")); + public static readonly string labelCollision = (Localization.Tr("Collision")); + public static readonly string labelSphere = (Localization.Tr("Sphere")); + public static readonly string labelCapsule = (Localization.Tr("Capsule")); + public static readonly string labelQuad = (Localization.Tr("Quad")); + public static readonly string labelFitCapsulePos = (Localization.Tr("Fit capsule place to parent")); + public static readonly string labelExcludeCollisionFromBone = (Localization.Tr("Exclude collision from SpringBone")); + public static readonly string labelDeleteCollier = (Localization.Tr("Delete collider of selection and children")); + public static readonly string labelCleanup = (Localization.Tr("Cleanup")); + public static readonly string labelShow = (Localization.Tr("Show")); + + public static readonly string labelShowOnlySelectedBones = (Localization.Tr("Show only selected bones")); + public static readonly string labelShowBoneCollision = (Localization.Tr("Show bone collisions")); + public static readonly string labelShowOnlySelectedCollider = (Localization.Tr("Show only selected colliders")); + public static readonly string labelShowBoneName = (Localization.Tr("Show bone names")); + } + + private const string kIconDirectoryPath = "Packages/com.unity.springbone/Editor/GUI/Icons"; + + + [MenuItem("Window/Animation/SpringBone/SpringBone")] public static void ShowWindow() { - var window = GetWindow("スプリングボーン"); + var window = GetWindow(Styles.editorWindowTitle); window.OnShow(); } @@ -36,41 +79,24 @@ private static Texture LoadIcon(string iconDirectory, string filename) var iconTexture = AssetDatabase.LoadAssetAtPath(iconPath); if (iconTexture == null) { - Debug.LogWarning("アイコン読み込み失敗:\n" + iconPath); + Debug.LogFormat(LogType.Warning, LogOption.None, null, Styles.logIconDirNotFound, iconPath); } return iconTexture; } - private static string FindIconAssetDirectory() - { - // Try to find the icons in a way such that the user can put the Dynamics folder anywhere - return DirectoryUtil.GetFilesRecursively(Application.dataPath, "SpringCapsuleIcon.tga") - .Select(path => PathUtil.NormalizePath(path)) - .Where(path => path.ToLowerInvariant().Contains("editor/springbone/gui/icons/")) - .Select(path => PathUtil.SystemPathToAssetPath(System.IO.Path.GetDirectoryName(path))) - .FirstOrDefault(); - } - private void InitializeIcons() { if (headerIcon != null) { return; } - var iconDirectory = FindIconAssetDirectory(); - if (iconDirectory == null) - { - Debug.LogWarning("SpringBoneWindowのアイコンディレクトリーが見つかりません"); - return; - } - - headerIcon = LoadIcon(iconDirectory, "SpringIcon.tga"); - newDocumentIcon = LoadIcon(iconDirectory, "NewDocumentHS.png"); - openDocumentIcon = LoadIcon(iconDirectory, "OpenHH.bmp"); - saveDocumentIcon = LoadIcon(iconDirectory, "SaveHH.bmp"); - deleteIcon = LoadIcon(iconDirectory, "Delete.png"); - pivotIcon = LoadIcon(iconDirectory, "Pivot.png"); - sphereIcon = LoadIcon(iconDirectory, "SpringSphereIcon.tga"); - capsuleIcon = LoadIcon(iconDirectory, "SpringCapsuleIcon.tga"); - panelIcon = LoadIcon(iconDirectory, "SpringPanelIcon.tga"); + headerIcon = LoadIcon(kIconDirectoryPath, "SpringIcon.tga"); + newDocumentIcon = LoadIcon(kIconDirectoryPath, "NewDocumentHS.png"); + openDocumentIcon = LoadIcon(kIconDirectoryPath, "OpenHH.bmp"); + saveDocumentIcon = LoadIcon(kIconDirectoryPath, "SaveHH.bmp"); + deleteIcon = LoadIcon(kIconDirectoryPath, "Delete.png"); + pivotIcon = LoadIcon(kIconDirectoryPath, "Pivot.png"); + sphereIcon = LoadIcon(kIconDirectoryPath, "SpringSphereIcon.tga"); + capsuleIcon = LoadIcon(kIconDirectoryPath, "SpringCapsuleIcon.tga"); + panelIcon = LoadIcon(kIconDirectoryPath, "SpringPanelIcon.tga"); } private void InitializeButtonGroups() @@ -86,48 +112,48 @@ private void InitializeButtonGroups() { new GUIElements.Column(new GUIElements.IElement[] { - new GUIElements.Label("ダイナミクスCSV", headerLabelStyleProvider), + new GUIElements.Label(Styles.labelDynamicCSV, headerLabelStyleProvider), new GUIElements.Row(new GUIElements.IElement[] { - new GUIElements.Button("読み込む", LoadSpringBoneSetupWindow.ShowWindow, openDocumentIcon, buttonLabelStyleProvider), - new GUIElements.Button("保存", SaveSpringBoneSetupWindow.ShowWindow, saveDocumentIcon, buttonLabelStyleProvider) + new GUIElements.Button(Styles.labelLoad, LoadSpringBoneSetupWindow.ShowWindow, openDocumentIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelSave, SaveSpringBoneSetupWindow.ShowWindow, saveDocumentIcon, buttonLabelStyleProvider) }, BigButtonHeight) }), new GUIElements.Column(new GUIElements.IElement[] { - new GUIElements.Label("スプリングボーン", headerLabelStyleProvider), + new GUIElements.Label(Styles.labelSpringBone, headerLabelStyleProvider), new GUIElements.Row(new GUIElements.IElement[] { - new GUIElements.Button("スプリング\nボーン追加", SpringBoneEditorActions.AssignSpringBonesRecursively, headerIcon, buttonLabelStyleProvider), - new GUIElements.Button("基点作成", SpringBoneEditorActions.CreatePivotForSpringBones, pivotIcon, buttonLabelStyleProvider) + new GUIElements.Button(Styles.labelSpringBoneAdd, SpringBoneEditorActions.AssignSpringBonesRecursively, headerIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelCreateOrigin, SpringBoneEditorActions.CreatePivotForSpringBones, pivotIcon, buttonLabelStyleProvider) }, BigButtonHeight), - new GUIElements.Button("マネージャーを作成/更新", SpringBoneEditorActions.AddToOrUpdateSpringManagerInSelection, newDocumentIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelCreateManager, SpringBoneEditorActions.AddToOrUpdateSpringManagerInSelection, newDocumentIcon, buttonLabelStyleProvider), //new GUIElements.Button("初期セットアップを行う", SpringBoneAutoSetupWindow.ShowWindow, newDocumentIcon, buttonLabelStyleProvider), //new GUIElements.Button("初期ボーンリストに合わせる", SpringBoneEditorActions.PromptToUpdateSpringBonesFromList, null, buttonLabelStyleProvider), new GUIElements.Separator(), - new GUIElements.Button("スプリングボーンをミラー", MirrorSpringBoneWindow.ShowWindow, null, buttonLabelStyleProvider), - new GUIElements.Button("選択と子供のスプリングボーンを選択", SpringBoneEditorActions.SelectChildSpringBones, null, buttonLabelStyleProvider), - new GUIElements.Button("選択スプリングボーンを削除", SpringBoneEditorActions.DeleteSelectedBones, deleteIcon, buttonLabelStyleProvider), - new GUIElements.Button("選択と子供のマネージャーとボーンを削除", SpringBoneEditorActions.DeleteSpringBonesAndManagers, deleteIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelMirrorBone, MirrorSpringBoneWindow.ShowWindow, null, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelSelectOneAndChild, SpringBoneEditorActions.SelectChildSpringBones, null, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelDeleteBone, SpringBoneEditorActions.DeleteSelectedBones, deleteIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelDeleteBoneAndManager, SpringBoneEditorActions.DeleteSpringBonesAndManagers, deleteIcon, buttonLabelStyleProvider), }), new GUIElements.Column(new GUIElements.IElement[] { - new GUIElements.Label("コリジョン", headerLabelStyleProvider), + new GUIElements.Label(Styles.labelCollision, headerLabelStyleProvider), new GUIElements.Row(new GUIElements.IElement[] { - new GUIElements.Button("球体", SpringColliderEditorActions.CreateSphereColliderBeneathSelectedObjects, sphereIcon, buttonLabelStyleProvider), - new GUIElements.Button("カプセル", SpringColliderEditorActions.CreateCapsuleColliderBeneathSelectedObjects, capsuleIcon, buttonLabelStyleProvider), - new GUIElements.Button("板", SpringColliderEditorActions.CreatePanelColliderBeneathSelectedObjects, panelIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelSphere, SpringColliderEditorActions.CreateSphereColliderBeneathSelectedObjects, sphereIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelCapsule, SpringColliderEditorActions.CreateCapsuleColliderBeneathSelectedObjects, capsuleIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelQuad, SpringColliderEditorActions.CreatePanelColliderBeneathSelectedObjects, panelIcon, buttonLabelStyleProvider), }, BigButtonHeight), - new GUIElements.Button("カプセルの位置を親に合わせる", SpringColliderEditorActions.AlignSelectedCapsulesToParents, capsuleIcon, buttonLabelStyleProvider), - new GUIElements.Button("スプリングボーンからコリジョンを外す", SpringColliderEditorActions.DeleteCollidersFromSelectedSpringBones, deleteIcon, buttonLabelStyleProvider), - new GUIElements.Button("選択と子供のコライダーを削除", SpringColliderEditorActions.DeleteAllChildCollidersFromSelection, deleteIcon, buttonLabelStyleProvider), - new GUIElements.Button("クリーンナップ", SpringColliderEditorActions.CleanUpDynamics, deleteIcon, buttonLabelStyleProvider) + new GUIElements.Button(Styles.labelFitCapsulePos, SpringColliderEditorActions.AlignSelectedCapsulesToParents, capsuleIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelExcludeCollisionFromBone, SpringColliderEditorActions.DeleteCollidersFromSelectedSpringBones, deleteIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelDeleteCollier, SpringColliderEditorActions.DeleteAllChildCollidersFromSelection, deleteIcon, buttonLabelStyleProvider), + new GUIElements.Button(Styles.labelCleanup, SpringColliderEditorActions.CleanUpDynamics, deleteIcon, buttonLabelStyleProvider) }) }, false, @@ -190,17 +216,17 @@ private float ShowHeaderUI(float xPos, float yPos, float uiWidth) System.Func toggleStyleProvider = () => SpringBoneGUIStyles.ToggleStyle; var headerColumn = new GUIElements.Column( new GUIElements.IElement[] { - new GUIElements.Label("表示", headerLabelStyleProvider), + new GUIElements.Label(Styles.labelShow, headerLabelStyleProvider), new GUIElements.Row(new GUIElements.IElement[] { - new GUIElements.Toggle("選択ボーンのみ表示", () => settings.onlyShowSelectedBones, newValue => { settings.onlyShowSelectedBones = newValue; needToRepaint = true; }, toggleStyleProvider), - new GUIElements.Toggle("ボーンのコリジョンを表示", () => settings.showBoneSpheres, newValue => { settings.showBoneSpheres = newValue; needToRepaint = true; }, toggleStyleProvider), + new GUIElements.Toggle(Styles.labelShowOnlySelectedBones, () => settings.onlyShowSelectedBones, newValue => { settings.onlyShowSelectedBones = newValue; needToRepaint = true; }, toggleStyleProvider), + new GUIElements.Toggle(Styles.labelShowBoneCollision, () => settings.showBoneSpheres, newValue => { settings.showBoneSpheres = newValue; needToRepaint = true; }, toggleStyleProvider), }, GUIElements.RowHeight), new GUIElements.Row(new GUIElements.IElement[] { - new GUIElements.Toggle("選択コライダーのみ表示", () => settings.onlyShowSelectedColliders, newValue => { settings.onlyShowSelectedColliders = newValue; needToRepaint = true; }, toggleStyleProvider), - new GUIElements.Toggle("ボーン名を表示", () => settings.showBoneNames, newValue => { settings.showBoneNames = newValue; needToRepaint = true; }, toggleStyleProvider) + new GUIElements.Toggle(Styles.labelShowOnlySelectedCollider, () => settings.onlyShowSelectedColliders, newValue => { settings.onlyShowSelectedColliders = newValue; needToRepaint = true; }, toggleStyleProvider), + new GUIElements.Toggle(Styles.labelShowBoneName, () => settings.showBoneNames, newValue => { settings.showBoneNames = newValue; needToRepaint = true; }, toggleStyleProvider) }, GUIElements.RowHeight), }, diff --git a/Editor/SpringBoneEditorActions.cs b/Editor/SpringBoneEditorActions.cs index bcf3f31..02ac2dd 100755 --- a/Editor/SpringBoneEditorActions.cs +++ b/Editor/SpringBoneEditorActions.cs @@ -3,11 +3,43 @@ using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public static class SpringBoneEditorActions { + private static class Styles + { + public static readonly string logStopPlayMode = Localization.Tr("You must stop Playmode first."); + public static readonly string logSelectOneOrMoreObjects = Localization.Tr("Select one or more objects."); + public static readonly string logSelectOnlyOneSpringManager = Localization.Tr("Select only one SpringManager"); + + public static readonly string textDelete = Localization.Tr("Delete"); + public static readonly string textCancel = Localization.Tr("Cancel"); + public static readonly string textUpdate = Localization.Tr("Update"); + + public static readonly string textDeleteSpringBoneAndManager = Localization.Tr("Delete SpringBone and Manager"); + public static readonly string textDeleteSelectedBones = Localization.Tr("Delete selected bones"); + + public static readonly string textUpdateFromBoneList = Localization.Tr("Update from bone list"); + + public static readonly string textConfirmRemoveAllBoneAndManagerFormat = Localization.Tr( + "Do you really want to remove all\n" + + "SpringBones and managers under this object?\n" + + "\n{0}"); + + public static readonly string textConfirmUpdateBonesFromListFormat = Localization.Tr( + "Do you want to update secondary bones from bone list?\n" + + "\nThis will remove all SpringBones that are not listed,\n" + + "and will add SpringBones missing in model.\n" + + "\nSpringManager: {0}\n"); + } + public static void ShowSpringBoneWindow() { SpringBoneWindow.ShowWindow(); @@ -17,13 +49,13 @@ public static void AssignSpringBonesRecursively() { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return; } if (Selection.gameObjects.Length < 1) { - Debug.LogError("一つ以上のオブジェクトを選択してください。"); + Debug.LogError(Styles.logSelectOneOrMoreObjects); return; } @@ -50,13 +82,13 @@ public static void CreatePivotForSpringBones() { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return; } if (Selection.gameObjects.Length < 1) { - Debug.LogError("一つ以上のオブジェクトを選択してください。"); + Debug.LogError(Styles.logSelectOneOrMoreObjects); return; } @@ -73,13 +105,13 @@ public static void AddToOrUpdateSpringManagerInSelection() { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return; } if (Selection.gameObjects.Length <= 0) { - Debug.LogError("一つ以上のオブジェクトを選択してください。"); + Debug.LogError(Styles.logSelectOneOrMoreObjects); return; } @@ -105,22 +137,20 @@ public static void DeleteSpringBonesAndManagers() { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return; } if (Selection.gameObjects.Length != 1) { - Debug.LogError("一つだけのルートオブジェクトを選択してください"); + Debug.LogError(Styles.logSelectOneOrMoreObjects); return; } var rootObject = Selection.gameObjects.First(); - var queryMessage = "本当にこのオブジェクトとその子供に入っている全ての\n" - + "スプリングボーンとスプリングマネージャーを削除しますか?\n\n" - + rootObject.name; + var queryMessage = string.Format(Styles.textConfirmRemoveAllBoneAndManagerFormat, rootObject.name); if (EditorUtility.DisplayDialog( - "スプリングボーンとマネージャーを削除", queryMessage, "削除", "キャンセル")) + Styles.textDeleteSpringBoneAndManager, queryMessage, Styles.textDelete, Styles.textCancel)) { SpringBoneSetup.DestroySpringManagersAndBones(rootObject); AssetDatabase.Refresh(); @@ -135,7 +165,7 @@ public static void DeleteSelectedBones() var springManagersToUpdate = GameObjectUtil.FindComponentsOfType() .Where(manager => manager.springBones.Any(bone => springBonesToDelete.Contains(bone))) .ToArray(); - Undo.RecordObjects(springManagersToUpdate, "Delete selected bones"); + Undo.RecordObjects(springManagersToUpdate, Styles.textDeleteSelectedBones); foreach (var boneToDelete in springBonesToDelete) { Undo.DestroyObjectImmediate(boneToDelete); @@ -150,7 +180,7 @@ public static void PromptToUpdateSpringBonesFromList() { if (Application.isPlaying) { - Debug.LogError("再生中に更新できません"); + Debug.LogError(Styles.logStopPlayMode); return; } @@ -165,16 +195,14 @@ public static void PromptToUpdateSpringBonesFromList() if (selectedSpringManagers.Count() != 1) { - Debug.LogError("一つだけのSpringManagerを選択してください"); + Debug.LogError(Styles.logSelectOnlyOneSpringManager); return; } var springManager = selectedSpringManagers.First(); - var queryMessage = "ボーンリストから揺れものボーンを更新しますか?\n\n" - + "リストにないSpringBone情報は削除され、\n" - + "モデルにないSpringBone情報は追加されます。\n\n" - + "SpringManager: " + springManager.name; - if (EditorUtility.DisplayDialog("ボーンリストから更新", queryMessage, "更新", "キャンセル")) + var queryMessage = string.Format(Styles.textConfirmUpdateBonesFromListFormat, springManager.name); + + if (EditorUtility.DisplayDialog(Styles.textUpdateFromBoneList, queryMessage, Styles.textUpdate, Styles.textCancel)) { AutoSpringBoneSetup.UpdateSpringManagerFromBoneList(springManager); } diff --git a/Editor/SpringColliderEditorActions.cs b/Editor/SpringColliderEditorActions.cs index f459801..b3a8f2a 100755 --- a/Editor/SpringColliderEditorActions.cs +++ b/Editor/SpringColliderEditorActions.cs @@ -3,16 +3,38 @@ using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public static class SpringColliderEditorActions { + private static class Styles + { + public static readonly string logStopPlayMode = Localization.Tr("You must stop Playmode first."); + public static readonly string textAlignCapsulesToParent = Localization.Tr("Align capsules to parents"); + public static readonly string textConfirmDeleteCollisions = Localization.Tr("Do you really want to remove collisions from selected SpringBones?"); + public static readonly string textRemoveCollisions = Localization.Tr("Remove Collisions"); + public static readonly string textRemove = Localization.Tr("Remove"); + public static readonly string textCancel = Localization.Tr("Cancel"); + public static readonly string textRemoveDuplicateComponents = Localization.Tr("Remove duplicate components"); + public static readonly string textCleanupSpringBone = Localization.Tr("Cleanup SpringBones"); + public static readonly string textConfirmDynamicCleanup = Localization.Tr("Do you really want to cleanup dynamics?"); + public static readonly string textCleanupDynamics = Localization.Tr("Cleanup Dynamics"); + public static readonly string textRemoveAllChildColliders = Localization.Tr("Remove all selected child colliders"); + public static readonly string textConfirmRemoveAllChildColliders = Localization.Tr("Do you really want to remove all colliders from children?"); + public static readonly string textRemoveSelectedColliders = Localization.Tr("Remove Colliders"); + } + public static IList CreateObjectsWithComponentBeneathSelectedObjects(string suffix) where T : Component { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return new List(); } @@ -43,7 +65,7 @@ public static void AlignCapsulesToParents(IEnumerable cap var undoObjects = new List(); undoObjects.AddRange(capsules.Select(item => (Object)item)); undoObjects.AddRange(capsules.Select(item => (Object)item.transform)); - Undo.RecordObjects(undoObjects.ToArray(), "Align capsules to parents"); + Undo.RecordObjects(undoObjects.ToArray(), Styles.textAlignCapsulesToParent); foreach (var capsule in capsules) { capsule.transform.localPosition = Vector3.zero; @@ -96,7 +118,7 @@ public static void DeleteCollidersFromSelectedSpringBones() { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return; } @@ -105,10 +127,10 @@ public static void DeleteCollidersFromSelectedSpringBones() .Where(bone => bone != null); if (!selectedBones.Any()) { return; } - var queryMessage = "本当に選択SpringBoneのコリジョンを削除しますか?"; - if (EditorUtility.DisplayDialog("コリジョンを削除", queryMessage, "削除", "キャンセル")) + var queryMessage = Styles.textConfirmDeleteCollisions; + if (EditorUtility.DisplayDialog(Styles.textConfirmDeleteCollisions, queryMessage, Styles.textRemove, Styles.textCancel)) { - Undo.RecordObjects(selectedBones.ToArray(), "コリジョンを削除"); + Undo.RecordObjects(selectedBones.ToArray(), Styles.textRemoveCollisions); foreach (var springBone in selectedBones) { springBone.RemoveAllColliders(); @@ -120,14 +142,14 @@ public static void DeleteAllChildCollidersFromSelection() { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return; } if (Selection.gameObjects.Length == 0) { return; } - var queryMessage = "本当に選択中のオブジェクトの全子供のコライダーを削除しますか?"; - if (!EditorUtility.DisplayDialog("選択コライダーを削除", queryMessage, "削除", "キャンセル")) + var queryMessage = Styles.textConfirmRemoveAllChildColliders; + if (!EditorUtility.DisplayDialog(Styles.textRemoveSelectedColliders, queryMessage, Styles.textRemove, Styles.textCancel)) { return; } @@ -158,7 +180,7 @@ public static void DeleteAllChildCollidersFromSelection() var undoObjects = new List(springBones.Select(item => (Object)item)); undoObjects.AddRange(deadColliders.Select(item => (Object)item)); undoObjects.AddRange(probablyDeadGameObjects.Select(item => (Object)item)); - Undo.RecordObjects(undoObjects.ToArray(), "Remove all selected child colliders"); + Undo.RecordObjects(undoObjects.ToArray(), Styles.textRemoveAllChildColliders); foreach (var springBone in springBones) { @@ -182,15 +204,15 @@ public static void CleanUpDynamics() { if (Application.isPlaying) { - Debug.LogError("再生モードを止めてください。"); + Debug.LogError(Styles.logStopPlayMode); return; } var springManagers = GameObjectUtil.FindComponentsOfType(); if (!springManagers.Any()) { return; } - var queryMessage = "本当にダイナミクスのクリーンナップを行いますか?"; - if (EditorUtility.DisplayDialog("ダイナミクスクリーンナップ", queryMessage, "削除", "キャンセル")) + var queryMessage = Styles.textConfirmDynamicCleanup; + if (EditorUtility.DisplayDialog(Styles.textCleanupDynamics, queryMessage, Styles.textRemove, Styles.textCancel)) { RemoveDuplicateComponents(); RemoveDuplicateComponents(); @@ -239,7 +261,7 @@ public static void CleanUpDynamics() } // Next remove all empty entries from SpringBones - Undo.RecordObjects(springBones.ToArray(), "SpringBone cleanup"); + Undo.RecordObjects(springBones.ToArray(), Styles.textCleanupSpringBone); foreach (var springBone in springBones) { springBone.capsuleColliders = springBone.capsuleColliders.Where(item => item != null).ToArray(); @@ -265,7 +287,7 @@ private static void RemoveDuplicateComponents() where T : Component .Where(item => item.GetComponents().Length > 1); if (duplicateObjects.Any()) { - Undo.RecordObjects(duplicateObjects.ToArray(), "Remove duplicate components"); + Undo.RecordObjects(duplicateObjects.ToArray(), Styles.textRemoveDuplicateComponents); foreach (var transform in duplicateObjects) { var components = transform.GetComponents(); diff --git a/Editor/Utility/FindGameObjectsWindow.cs b/Editor/Utility/FindGameObjectsWindow.cs index 01b84eb..0e48b10 100755 --- a/Editor/Utility/FindGameObjectsWindow.cs +++ b/Editor/Utility/FindGameObjectsWindow.cs @@ -3,15 +3,31 @@ using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public class FindGameObjectsWindow : EditorWindow { - [MenuItem("UTJ/名前で選択窓")] + private static class Styles + { + public static readonly string editorWindowTitle = Localization.Tr("Name Selector Tool"); + + public static readonly string textName = Localization.Tr("Name"); + public static readonly string textIgnore = Localization.Tr("Ignore"); + public static readonly string textComponent = Localization.Tr("Component"); + public static readonly string textSelect = Localization.Tr("Select"); + public static readonly string textSelectingMultipleObjectFormat = Localization.Tr("Selecting {0} objects"); + } + + [MenuItem("Window/Animation/SpringBone/Name Selector Tool")] public static void ShowWindow() { - var window = GetWindow("名前で選択"); + var window = GetWindow(Styles.editorWindowTitle); window.OnShow(); } @@ -278,18 +294,18 @@ private void OnGUI() var rowWidth = position.width - Spacing * 2f; var fieldPositions = GetTextFieldPositions(Spacing, Spacing, rowWidth, RowHeight, Spacing); - DoTextFieldWithClearButton(ref fieldPositions, "名前", ref objectPattern, RestartSearchCountdown, SearchNameField); + DoTextFieldWithClearButton(ref fieldPositions, Styles.textName, ref objectPattern, RestartSearchCountdown, SearchNameField); fieldPositions.y += RowOffset; - DoTextFieldWithClearButton(ref fieldPositions, "無視", ref ignorePattern, RestartSearchCountdown); + DoTextFieldWithClearButton(ref fieldPositions, Styles.textIgnore, ref ignorePattern, RestartSearchCountdown); fieldPositions.y += RowOffset; - DoTextFieldWithClearButton(ref fieldPositions, "コンポーネント", ref componentPattern, RestartSearchCountdown); + DoTextFieldWithClearButton(ref fieldPositions, Styles.textComponent, ref componentPattern, RestartSearchCountdown); fieldPositions.y += RowOffset; var rowRect = new Rect(fieldPositions.x, fieldPositions.y, rowWidth, RowHeight); - if (GUI.Button(rowRect, "選択")) { FindAndSelectObjects(); } + if (GUI.Button(rowRect, Styles.textSelect)) { FindAndSelectObjects(); } rowRect.y += RowOffset; - var message = Selection.objects.Length.ToString() + " 個のオブジェクトを選択中"; + var message = string.Format(Styles.textSelectingMultipleObjectFormat, Selection.objects.Length); GUI.Label(rowRect, message); if (isInitialShow) diff --git a/Editor/Utility/SetObjectParentWindow.cs b/Editor/Utility/SetObjectParentWindow.cs index 9db5374..4fc72b0 100755 --- a/Editor/Utility/SetObjectParentWindow.cs +++ b/Editor/Utility/SetObjectParentWindow.cs @@ -1,15 +1,29 @@ using System.Linq; using UnityEditor; using UnityEngine; +#if UNITY_2020_2_OR_NEWER +using Localization = UnityEditor.L10n; +#else +using Localization = UnityEditor.Localization.Editor.Localization; +#endif namespace Unity.Animations.SpringBones { public class SetObjectParentWindow : EditorWindow { - [MenuItem("UTJ/親子付け")] + private static class Styles + { + public static readonly string editorWindowTitle = Localization.Tr("Parenting Tool"); + + public static readonly GUIContent labelNewParent = new GUIContent(Localization.Tr("New Parent")); + public static readonly GUIContent labelSetParent = new GUIContent(Localization.Tr("Set Parent")); + } + + + [MenuItem("Window/Animation/SpringBone/Parenting Tool")] public static void ShowWindow() { - GetWindow("親子付け"); + GetWindow(Styles.editorWindowTitle); } // private @@ -31,9 +45,9 @@ private void ReparentSelectedObjects() private void OnGUI() { EditorGUILayout.Space(); - newParent = EditorGUILayout.ObjectField("新しい親", newParent, typeof(Transform), true) as Transform; + newParent = EditorGUILayout.ObjectField(Styles.labelNewParent, newParent, typeof(Transform), true) as Transform; EditorGUILayout.Space(); - if (GUILayout.Button("親子付け")) + if (GUILayout.Button(Styles.labelSetParent)) { ReparentSelectedObjects(); } diff --git a/Editor/com.unity.animations.springbone.editor.asmdef b/Editor/com.unity.animations.springbone.editor.asmdef index f406c98..2964823 100644 --- a/Editor/com.unity.animations.springbone.editor.asmdef +++ b/Editor/com.unity.animations.springbone.editor.asmdef @@ -3,12 +3,15 @@ "references": [ "com.unity.animations.springbone" ], - "optionalUnityReferences": [], - "includePlatforms": [], + "includePlatforms": [ + "Editor" + ], "excludePlatforms": [], "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, - "defineConstraints": [] + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/Editor/ja.po b/Editor/ja.po new file mode 100644 index 0000000..23cdb57 --- /dev/null +++ b/Editor/ja.po @@ -0,0 +1,383 @@ +msgid "" +msgstr "" +"POT-Creation-Date: Tue Jul 15 2020 05:00:00 GMT+0000 (Coordinated Universal " +"Time)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.3\n" +"Language: ja\n" +"Project-Id-Version: 54\n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" + +# MenuItem +msgid "Parenting Tool" +msgstr "親子付けツール" + +# MenuItem +msgid "Name Selector Tool" +msgstr "名前選択ツール" + +# MenuItem +msgid "SpringBone" +msgstr "スプリングボーン" + +msgid "Loading Configuration" +msgstr "読み込み設定" + +msgid "Cancel" +msgstr "キャンセル" + +msgid "Set up from CSV file" +msgstr "CSVを読み込んでセットアップ" + +msgid "Select root from selection" +msgstr "選択からルートを取得" + +msgid "SpringBone root" +msgstr "スプリングボーンのルート" + +msgid "Collider" +msgstr "コライダー" + +msgid "Do not setup in Play Mode" +msgstr "再生モードでセットアップしないでください" + +msgid "Select parent object of the spring bone" +msgstr "スプリングボーンの親オブジェクトを指定してください" + +msgid "Load spring bone setup" +msgstr "スプリングボーンセットアップを読み込む" + +msgid "" +"Set up complete:{0}\n" +"Number of bones: {1} Number of colliders: {2}" +msgstr "" +"セットアップ完了: {0}\n" +"ボーン数: {1} コライダー数: {2}" + +msgid "CSV File" +msgstr "CSVファイル" + +msgid "Text File" +msgstr "テキストファイル" + +msgid "" +"SpringBone setup failed.\n" +"Souce data may contain errors,\n" +"or the data don't match the character.\n" +"Please refer console logs for further info.\n" +"\n" +"Character: {0}\n" +"\n" +"Path: {1}" +msgstr "" +"スプリングボーンセットアップが失敗しました。\n" +"元データにエラーがあるか、もしくは\n" +"キャラクターにデータが一致しません。\n" +"詳しくはConsoleのログをご覧下さい。\n" +"\n" +"キャラクター: {0}\n" +"\n" +"パス: {1}" + +msgid "SpringBone Setup" +msgstr "スプリングボーンセットアップ" + +msgid "SpringBone Setup failed:{0}\nPath:{1}" +msgstr "スプリングボーンセットアップ失敗:{0}\nPath:{1}" + +msgid "SpringBone Mirror" +msgstr "SpringBoneミラー" + +msgid "Do Mirror" +msgstr "ミラーを行う" + +msgid "Get from selection" +msgstr "選択から取得" + +msgid "Select All" +msgstr "全選択" + +msgid "Select all copy destination" +msgstr "コピー先を全選択" + +msgid "Select all copy source" +msgstr "コピー元を全選択" + +msgid "Set bone where X > 0" +msgstr "X > 0のボーンを元に設定" + +msgid "Set bone where X < 0" +msgstr "X < 0のボーンを元に設定" + +msgid "Source" +msgstr "元" + +msgid "→ Destination" +msgstr "→ 先" + +msgid "Save SpringBone Setup" +msgstr "スプリングボーンセットアップを保存" + +msgid "Export Setting" +msgstr "書き出し設定" + +msgid "Get root from selection" +msgstr "選択からルートを取得" + +msgid "Save to CSV" +msgstr "CSVを保存" + +msgid "" +"File already exists. Overwrite?\n" +"\n" +msgstr "" +"ファイルは既に存在します。上書きしますか?\n" +"\n" + +msgid "Save SpringBone" +msgstr "スプリングボーン保存" + +msgid "Overwrite" +msgstr "上書き" + +msgid "Saved.: {0}" +msgstr "保存しました: {0}" + +msgid "Setup Dynamics" +msgstr "ダイナミクスセットアップ" + +msgid "" +"There are errors in dynamics setup. Do you want to create only ones without " +"error(s)?" +msgstr "" +"ダイナミクスセットアップに一部エラーが出ているものがあります。正常なものだけ" +"作成しますか?" + +msgid "SpringBone Root" +msgstr "スプリングボーンのルート" + +msgid "Collider Root" +msgstr "コライダーのルート" + +msgid "Path" +msgstr "パス" + +msgid "Create" +msgstr "作成" + +msgid "Error" +msgstr "エラー" + +msgid "Select by name" +msgstr "名前で選択" + +msgid "" +"Icon load failed:\n" +" Path:{0}" +msgstr "" +"アイコン読み込み失敗:\n" +" パス:{0}" + +msgid "SpringBoneWindow icon directory not found" +msgstr "SpringBoneWindowのアイコンディレクトリーが見つかりません" + +msgid "Load" +msgstr "読み込む" + +msgid "Save" +msgstr "保存" + +msgid "Dynamics CSV" +msgstr "ダイナミクスCSV" + +msgid "" +"Add\n" +"SpringBone" +msgstr "" +"スプリング\n" +"ボーン追加" + +msgid "Create Origin" +msgstr "基点作成" + +msgid "Create or Update Manager" +msgstr "マネージャーを作成/更新" + +msgid "Do Initial Setup" +msgstr "初期セットアップを行う" + +msgid "Fit to initial bone list" +msgstr "初期ボーンリストに合わせる" + +msgid "Mirror SpringBones" +msgstr "スプリングボーンをミラー" + +msgid "Select this and child bones" +msgstr "選択と子供のスプリングボーンを選択" + +msgid "Delete SpringBone" +msgstr "選択スプリングボーンを削除" + +msgid "Delete Managers and Bones of Selection and Children" +msgstr "選択と子供のマネージャーとボーンを削除" + +msgid "Collision" +msgstr "コリジョン" + +msgid "Sphere" +msgstr "球体" + +msgid "Capsule" +msgstr "カプセル" + +msgid "Quad" +msgstr "板" + +msgid "Fit capsule place to parent" +msgstr "カプセルの位置を親に合わせる" + +msgid "Exclude collision from SpringBone" +msgstr "スプリングボーンからコリジョンを外す" + +msgid "Delete collider of selection and children" +msgstr "選択と子供のコライダーを削除" + +msgid "Cleanup" +msgstr "クリーンナップ" + +msgid "Show" +msgstr "表示" + +msgid "Show only selected bones" +msgstr "選択ボーンのみ表示" + +msgid "Show bone collisions" +msgstr "ボーンのコリジョンを表示" + +msgid "Show only selected colliders" +msgstr "選択コライダーのみ表示" + +msgid "Show bone names" +msgstr "ボーン名を表示" + +msgid "Selecting {0} objects" +msgstr "{0} 個のオブジェクトを選択中" + +msgid "Set Parent" +msgstr "親子付け" + +msgid "New Parent" +msgstr "新しい親" + +msgid "Dynamics bone not found:{0}" +msgstr "ダイナミクス骨が見つかりません:{0}" + +msgid "Stop Play Mode" +msgstr "再生モードを止めてください" + +msgid "Select one or more objects." +msgstr "一つ以上のオブジェクトを選択してください。" + +msgid "Select only one root object" +msgstr "一つだけのルートオブジェクトを選択してください" + +msgid "" +"Do you really want to remove all\n" +"SpringBones and managers under this object?\n" +"\n{0}" +msgstr "" +"本当にこのオブジェクトとその子供に入っている全ての\n" +"スプリングボーンとスプリングマネージャーを削除しますか?\n" +"\n{0}" + +msgid "Delete SpringBone and Manager" +msgstr "スプリングボーンとマネージャーを削除" + +msgid "Delete" +msgstr "削除" + +msgid "Can't update while in Play Mode" +msgstr "再生中に更新できません" + +msgid "Select only one SpringManager" +msgstr "一つだけのSpringManagerを選択してください" + +msgid "" +"Do you want to update secondary bones from bone list?\n" +"\n" +"This will remove all SpringBones that are not listed,\n" +"and will add SpringBones missing in model.\n" +"\n" +"SpringManager: {0}\n" +msgstr "" +"ボーンリストから揺れものボーンを更新しますか?\n" +"\n" +"リストにないSpringBone情報は削除され、\n" +"モデルにないSpringBone情報は追加されます。\n" +"\n" +"SpringManager: {0}\n" + +msgid "Update from bone list" +msgstr "ボーンリストから更新" + +msgid "Update" +msgstr "更新" + +msgid "Ignore" +msgstr "無視" + +msgid "Component" +msgstr "コンポーネント" + +msgid "Name" +msgstr "名前" + +msgid "Select" +msgstr "選択" + +msgid "New Parent" +msgstr "新しい親" + +msgid "You must stop Playmode first." +msgstr "この操作を行うには、プレイモードを停止してください。" + +msgid "Align capsules to parents" +msgstr "カプセルを親に合わせる" + +msgid "Do you really want to remove collisions from selected SpringBones?" +msgstr "本当に選択SpringBoneのコリジョンを削除しますか?" + +msgid "Remove Collisions" +msgstr "コリジョンを削除" + +msgid "Remove duplicate components" +msgstr "重複したコンポーネントを削除" + +msgid "Cleanup SpringBones" +msgstr "スプリングボーンをクリーンアップ" + +msgid "Do you really want to cleanup dynamics?" +msgstr "本当にダイナミクスのクリーンアップを行いますか?" + +msgid "Cleanup Dynamics" +msgstr "ダイナミクスをクリーンアップ" + +msgid "Remove all selected child colliders" +msgstr "選択中の子のコライダーを全て削除" + +msgid "Do you really want to remove all colliders from children?" +msgstr "本当に選択中のオブジェクトの全子供のコライダーを削除しますか?" + +msgid "Remove Colliders" +msgstr "コライダーを削除" + +msgid "Remove" +msgstr "削除" + +msgid "Delete selected bones" +msgstr "選択したボーンを削除" diff --git a/Editor/ja.po.meta b/Editor/ja.po.meta new file mode 100644 index 0000000..b175db6 --- /dev/null +++ b/Editor/ja.po.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 32c431e98808145fdb3cfb443a74f97f +LocalizationImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Colliders/SpringCapsuleCollider.cs b/Runtime/Colliders/SpringCapsuleCollider.cs index b012277..0e43911 100755 --- a/Runtime/Colliders/SpringCapsuleCollider.cs +++ b/Runtime/Colliders/SpringCapsuleCollider.cs @@ -147,7 +147,7 @@ public void DrawGizmos(Color drawColor) endRingPoints = new Vector3[PointCount]; } - var worldRadius = transform.TransformDirection(radius, 0f, 0f).magnitude; + var worldRadius = transform.TransformVector(radius, 0f, 0f).magnitude; var startCapOrigin = transform.position; var endCapOrigin = transform.TransformPoint(0f, height, 0f); @@ -221,7 +221,7 @@ private void DrawPickBox() var start = transform.position; var end = transform.TransformPoint(0f, height, 0f); var center = 0.5f * (start + end); - var worldRadius = 1.5f * transform.TransformDirection(radius, 0f, 0f).magnitude; + var worldRadius = 1.5f * transform.TransformVector(radius, 0f, 0f).magnitude; var size = new Vector3( Mathf.Abs(end.x - start.x) + worldRadius, Mathf.Abs(end.y - start.y) + worldRadius, @@ -259,7 +259,7 @@ SpringBone.CollisionStatus collisionStatus var localContactPoint = new Vector3(originToContactPoint.x, localMoverPosition.y, originToContactPoint.z); var worldContactPoint = transform.TransformPoint(localContactPoint); var worldNormal = transform.TransformDirection(localNormal).normalized; - var worldRadius = transform.TransformDirection(localMoverRadius, 0f, 0f).magnitude; + var worldRadius = transform.TransformVector(localMoverRadius, 0f, 0f).magnitude; m_colliderDebugger.RecordCollision( worldContactPoint, worldNormal, diff --git a/Runtime/Colliders/SpringPanelCollider.cs b/Runtime/Colliders/SpringPanelCollider.cs index 2af6ba1..6e22219 100755 --- a/Runtime/Colliders/SpringPanelCollider.cs +++ b/Runtime/Colliders/SpringPanelCollider.cs @@ -32,14 +32,14 @@ ref Vector3 hitNormal } var localTailPosition = transform.InverseTransformPoint(tailPosition); - var localTailRadius = transform.InverseTransformDirection(tailRadius, 0f, 0f).magnitude; + var localTailRadius = transform.InverseTransformVector(tailRadius, 0f, 0f).magnitude; if (localTailPosition.z >= localTailRadius) { return SpringBone.CollisionStatus.NoCollision; } var localHeadPosition = transform.InverseTransformPoint(headPosition); - var localLength = transform.InverseTransformDirection(length, 0f, 0f).magnitude; + var localLength = transform.InverseTransformVector(length, 0f, 0f).magnitude; var halfWidth = 0.5f * width; var halfHeight = 0.5f * height; diff --git a/Runtime/Colliders/SpringSphereCollider.cs b/Runtime/Colliders/SpringSphereCollider.cs index a0d53af..7dabef3 100755 --- a/Runtime/Colliders/SpringSphereCollider.cs +++ b/Runtime/Colliders/SpringSphereCollider.cs @@ -20,7 +20,7 @@ ref Vector3 hitNormal { var localHeadPosition = transform.InverseTransformPoint(headPosition); var localTailPosition = transform.InverseTransformPoint(tailPosition); - var localTailRadius = transform.InverseTransformDirection(tailRadius, 0f, 0f).magnitude; + var localTailRadius = transform.InverseTransformVector(tailRadius, 0f, 0f).magnitude; #if UNITY_EDITOR var originalLocalTailPosition = localTailPosition; @@ -141,7 +141,7 @@ public static Vector3 ComputeNewTailPosition(Circle3 intersection, Vector3 tailP public void DrawGizmos(Color drawColor) { - var worldRadius = transform.TransformDirection(radius, 0f, 0f).magnitude; + var worldRadius = transform.TransformVector(radius, 0f, 0f).magnitude; // For picking Gizmos.color = new Color(0f, 0f, 0f, 0f); Gizmos.DrawWireSphere(transform.position, worldRadius); diff --git a/Runtime/SpringBone.cs b/Runtime/SpringBone.cs index 96ee1dd..784988c 100755 --- a/Runtime/SpringBone.cs +++ b/Runtime/SpringBone.cs @@ -264,7 +264,7 @@ private bool CheckForCollision() { var desiredPosition = currTipPos; var headPosition = transform.position; - var scaledRadius = transform.TransformDirection(radius, 0f, 0f).magnitude; + var scaledRadius = transform.TransformVector(radius, 0f, 0f).magnitude; var hitNormal = new Vector3(0f, 0f, 1f); var hadCollision = false; @@ -333,7 +333,7 @@ private bool CheckForGroundCollision() // Todo: this assumes a flat ground parallel to the xz plane var worldHeadPosition = transform.position; var worldTailPosition = currTipPos; - var worldRadius = transform.TransformDirection(radius, 0f, 0f).magnitude; + var worldRadius = transform.TransformVector(radius, 0f, 0f).magnitude; var worldLength = (currTipPos - worldHeadPosition).magnitude; var groundHeight = manager.groundHeight; worldHeadPosition.y -= groundHeight; @@ -432,7 +432,7 @@ private Vector3 ApplyLengthLimits(float deltaTime) public void DrawSpringBoneCollision() { var childPosition = ComputeChildPosition(); - var worldRadius = transform.TransformDirection(radius, 0f, 0f).magnitude; + var worldRadius = transform.TransformVector(radius, 0f, 0f).magnitude; // For picking Gizmos.DrawSphere(childPosition, worldRadius); diff --git a/Tests.meta b/Tests.meta new file mode 100644 index 0000000..721eeb5 --- /dev/null +++ b/Tests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef86cb67fc1f03d46b608902bad1bf53 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor.meta b/Tests/Editor.meta new file mode 100644 index 0000000..0e142e2 --- /dev/null +++ b/Tests/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 699cda04c9d44324db6d60e77838f827 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/NewTestScript.cs b/Tests/Editor/NewTestScript.cs new file mode 100644 index 0000000..f16e70c --- /dev/null +++ b/Tests/Editor/NewTestScript.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; + +namespace Tests +{ + public class NewTestScript + { + // A Test behaves as an ordinary method + [Test] + public void NewTestScriptSimplePasses() + { + // Use the Assert class to test conditions + } + + // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use + // `yield return null;` to skip a frame. + [UnityTest] + public IEnumerator NewTestScriptWithEnumeratorPasses() + { + // Use the Assert class to test conditions. + // Use yield to skip a frame. + yield return null; + } + } +} diff --git a/Tests/Editor/NewTestScript.cs.meta b/Tests/Editor/NewTestScript.cs.meta new file mode 100644 index 0000000..d13b8a1 --- /dev/null +++ b/Tests/Editor/NewTestScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29b05809868220346acdc899c15495d9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/Unity.Springbone.Tests.Editor.asmdef b/Tests/Editor/Unity.Springbone.Tests.Editor.asmdef new file mode 100644 index 0000000..f53742c --- /dev/null +++ b/Tests/Editor/Unity.Springbone.Tests.Editor.asmdef @@ -0,0 +1,22 @@ +{ + "name": "Unity.Springbone.Tests.Editor", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Tests/Editor/Unity.Springbone.Tests.Editor.asmdef.meta b/Tests/Editor/Unity.Springbone.Tests.Editor.asmdef.meta new file mode 100644 index 0000000..f01755c --- /dev/null +++ b/Tests/Editor/Unity.Springbone.Tests.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6bded67ef16ee2a41b4a0e8a467ed6fb +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json index 6e2ad13..90d1efc 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "com.unity.springbone", "displayName": "Unity Chan Spring Bone", - "version": "1.1.0-preview", - "unity": "2018.3", + "version": "1.2.2", + "unity": "2019.4", "description": "Sping Bone System for lightweight secondary animations.", "keywords": ["animation"], "category": "Animation",