diff --git a/Assets/chocopoi/DressingTools/Editor/DressCheckCodeMask.cs b/Assets/chocopoi/DressingTools/Editor/DressCheckCodeMask.cs index 1cb06f93..6bd05437 100644 --- a/Assets/chocopoi/DressingTools/Editor/DressCheckCodeMask.cs +++ b/Assets/chocopoi/DressingTools/Editor/DressCheckCodeMask.cs @@ -13,6 +13,8 @@ public enum Info EXISTING_PREFIX_DETECTED_AND_REMOVED = 0x08, EXISTING_SUFFIX_DETECTED_NOT_REMOVED = 0x10, EXISTING_SUFFIX_DETECTED_AND_REMOVED = 0x20, + ARMATURE_OBJECT_GUESSED = 0x40, + MULTIPLE_BONES_IN_AVATAR_ARMATURE_FIRST_LEVEL_WARNING_REMOVED = 0x80 //only one enabled bone detected, others are disabled (e.g. Maya has a C object that is disabled) } public enum Warn @@ -31,6 +33,6 @@ public enum Error NULL_ACTIVE_AVATAR_OR_CLOTHES = 0x04, NO_BONES_IN_AVATAR_ARMATURE_FIRST_LEVEL = 0x08, NO_BONES_IN_CLOTHES_ARMATURE_FIRST_LEVEL = 0x10, - CLOTHES_IS_A_PREFAB = 0x20, + CLOTHES_IS_A_PREFAB = 0x20 } } diff --git a/Assets/chocopoi/DressingTools/Editor/DressingToolsWindow.cs b/Assets/chocopoi/DressingTools/Editor/DressingToolsWindow.cs index 63232863..ce70794a 100644 --- a/Assets/chocopoi/DressingTools/Editor/DressingToolsWindow.cs +++ b/Assets/chocopoi/DressingTools/Editor/DressingToolsWindow.cs @@ -161,6 +161,11 @@ private void DrawToolHeaderGUI() EditorGUILayout.Separator(); + if (CHECK_UPDATE_STATUS == 2 && TOOL_VERSION != ONLINE_VERSION) + { + EditorGUILayout.HelpBox(t._("label_update_available", ONLINE_VERSION), MessageType.Warning); + } + EditorGUILayout.HelpBox(t._("label_header_tool_description"), MessageType.Info); DrawHorizontalLine(); @@ -321,6 +326,16 @@ private void DrawDressReportDetails() { EditorGUILayout.HelpBox(t._("helpbox_info_existing_suffix_detected_not_removed"), MessageType.Info); } + + if ((dressReport.infos & DressCheckCodeMask.Info.ARMATURE_OBJECT_GUESSED) == DressCheckCodeMask.Info.ARMATURE_OBJECT_GUESSED) + { + EditorGUILayout.HelpBox(t._("helpbox_info_armature_object_guessed"), MessageType.Info); + } + + if ((dressReport.infos & DressCheckCodeMask.Info.MULTIPLE_BONES_IN_AVATAR_ARMATURE_FIRST_LEVEL_WARNING_REMOVED) == DressCheckCodeMask.Info.MULTIPLE_BONES_IN_AVATAR_ARMATURE_FIRST_LEVEL_WARNING_REMOVED) + { + EditorGUILayout.HelpBox(t._("helpbox_info_multiple_bones_in_clothes_armature_first_level_warning_removed"), MessageType.Info); + } } private DressSettings MakeDressSettings() @@ -441,8 +456,12 @@ private void DrawAdvancedGUI() " " + t._("radio_db_remove_and_parent_const"), " " + t._("radio_db_keep_clothes_and_parent_const_if_need"), " " + t._("radio_db_create_child_and_exclude"), + " " + t._("radio_db_copy_dyn_bone_to_clothes"), " " + t._("radio_db_ignore_all") - }, 1, radioStyle, GUILayout.ExpandHeight(true), GUILayout.MaxHeight(150)); + }, 1, radioStyle, GUILayout.ExpandHeight(true), GUILayout.MaxHeight(200)); + + GUILayout.Label(t._("helpbox_info_dyn_bone_config_details")); + EditorGUILayout.SelectableLabel("https://github.com/poi-vrc/DressingTools/wiki/DynamicBone-Configuration"); } private void DrawToolContentGUI() diff --git a/Assets/chocopoi/DressingTools/Editor/Rules/ArmatureRule.cs b/Assets/chocopoi/DressingTools/Editor/Rules/ArmatureRule.cs index 081798d8..e7cd2fea 100644 --- a/Assets/chocopoi/DressingTools/Editor/Rules/ArmatureRule.cs +++ b/Assets/chocopoi/DressingTools/Editor/Rules/ArmatureRule.cs @@ -36,7 +36,7 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level, // Find whether there is a DynamicBone component in the bone DynamicBone avatarDynBone = avatarTrans?.GetComponent(); - DynamicBone childDynBone = child?.GetComponent(); + DynamicBone childDynBone = child.GetComponent(); if (avatarDynBone != null || childDynBone != null) { @@ -44,7 +44,10 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level, { if (avatarDynBone != null) { - Object.DestroyImmediate(childDynBone); + if (childDynBone != null) + { + Object.DestroyImmediate(childDynBone); + } ParentConstraint comp = child.gameObject.AddComponent(); comp.constraintActive = true; @@ -61,7 +64,7 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level, { if (childDynBone == null) { - ParentConstraint comp = childDynBone.gameObject.AddComponent(); + ParentConstraint comp = child.gameObject.AddComponent(); comp.constraintActive = true; ConstraintSource source = new ConstraintSource @@ -103,7 +106,24 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level, child.SetParent(dynBoneChild.transform); } } - else if (settings.dynamicBoneOption == 3) //ignore all + else if (settings.dynamicBoneOption == 3) //copy dyn bone to clothes bone + { +#if UNITY_EDITOR + if (avatarDynBone != null) + { + //destroy the existing dyn bone + if (childDynBone != null) + { + Object.DestroyImmediate(childDynBone); + } + + //copy component using unityeditor internal method (easiest way) + UnityEditorInternal.ComponentUtility.CopyComponent(avatarDynBone); + UnityEditorInternal.ComponentUtility.PasteComponentAsNew(child.gameObject); + } +#endif + } + else if (settings.dynamicBoneOption == 4) //ignore all { report.infos |= DressCheckCodeMask.Info.DYNAMIC_BONE_ALL_IGNORED; child.name = settings.prefixToBeAdded + child.name + settings.suffixToBeAdded; @@ -116,7 +136,7 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level, } if (!ProcessBone(report, settings, level + 1, avatarTrans, child)) - { + { return false; } } @@ -125,6 +145,19 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level, return true; } + public bool IsOnlyOneEnabledChildBone(Transform armature) + { + int count = 0; + for (int i = 0; i < armature.childCount; i++) + { + if (armature.GetChild(i).gameObject.activeSelf) + { + count++; + } + } + return count == 1; + } + public bool Evaluate(DressReport report, DressSettings settings, GameObject targetAvatar, GameObject targetClothes) { Transform avatarArmature = targetAvatar.transform.Find("Armature"); @@ -156,7 +189,15 @@ public bool Evaluate(DressReport report, DressSettings settings, GameObject targ if (avatarArmature.childCount > 1) { - report.warnings |= DressCheckCodeMask.Warn.MULTIPLE_BONES_IN_AVATAR_ARMATURE_FIRST_LEVEL; + //only one enabled bone detected, others are disabled (e.g. Maya has a C object that is disabled) + //otherwise the UI will always just say Compatible but not OK + if (IsOnlyOneEnabledChildBone(avatarArmature)) + { + report.infos |= DressCheckCodeMask.Info.MULTIPLE_BONES_IN_AVATAR_ARMATURE_FIRST_LEVEL_WARNING_REMOVED; + } else + { + report.warnings |= DressCheckCodeMask.Warn.MULTIPLE_BONES_IN_AVATAR_ARMATURE_FIRST_LEVEL; + } } if (clothesArmature.childCount > 1) diff --git a/Assets/chocopoi/DressingTools/Editor/Rules/ExistingPrefixSuffixRule.cs b/Assets/chocopoi/DressingTools/Editor/Rules/ExistingPrefixSuffixRule.cs index 5028ce6e..e3cce637 100644 --- a/Assets/chocopoi/DressingTools/Editor/Rules/ExistingPrefixSuffixRule.cs +++ b/Assets/chocopoi/DressingTools/Editor/Rules/ExistingPrefixSuffixRule.cs @@ -53,14 +53,47 @@ public void ProcessBone(DressReport report, DressSettings settings, Transform bo } } + public Transform GuessArmature(GameObject targetClothes) + { + List transforms = new List(); + + for (int i = 0; i < targetClothes.transform.childCount; i++) + { + Transform child = targetClothes.transform.GetChild(i); + + if (child.name.Contains("Armature")) + { + transforms.Add(child); + } + } + + if (transforms.Count == 1) + { + transforms[0].name = "Armature"; + return transforms[0]; + } else + { + return null; + } + } + public bool Evaluate(DressReport report, DressSettings settings, GameObject targetAvatar, GameObject targetClothes) { Transform clothesArmature = targetClothes.transform.Find("Armature"); if (!clothesArmature) { - report.errors |= DressCheckCodeMask.Error.NO_ARMATURE_IN_CLOTHES; - return false; + //guess the armature object by finding if the object name contains "Armature" and rename it + clothesArmature = GuessArmature(targetClothes); + + if (clothesArmature) + { + report.infos |= DressCheckCodeMask.Info.ARMATURE_OBJECT_GUESSED; + } else + { + report.errors |= DressCheckCodeMask.Error.NO_ARMATURE_IN_CLOTHES; + return false; + } } ProcessBone(report, settings, clothesArmature); diff --git a/Assets/chocopoi/DressingTools/Editor/TranslationKeys.cs b/Assets/chocopoi/DressingTools/Editor/TranslationKeys.cs index 6c575df9..19c209d2 100644 --- a/Assets/chocopoi/DressingTools/Editor/TranslationKeys.cs +++ b/Assets/chocopoi/DressingTools/Editor/TranslationKeys.cs @@ -44,6 +44,7 @@ public class TranslationKeys public string radio_db_remove_and_parent_const; public string radio_db_keep_clothes_and_parent_const_if_need; public string radio_db_create_child_and_exclude; + public string radio_db_copy_dyn_bone_to_clothes; public string radio_db_ignore_all; public string label_check_and_dress; @@ -83,7 +84,10 @@ public class TranslationKeys public string helpbox_info_existing_prefix_detected_not_removed; public string helpbox_info_existing_suffix_detected_and_removed; public string helpbox_info_existing_suffix_detected_not_removed; + public string helpbox_info_armature_object_guessed; + public string helpbox_info_multiple_bones_in_clothes_armature_first_level_warning_removed; + public string helpbox_info_dyn_bone_config_details; public string helpbox_info_move_clothes_into_place; public string helpbox_warn_exit_play_mode; public string dialog_test_mode_not_implemented; diff --git a/Assets/chocopoi/DressingTools/Translations/en.json b/Assets/chocopoi/DressingTools/Translations/en.json index f2e1582d..e6801830 100644 --- a/Assets/chocopoi/DressingTools/Translations/en.json +++ b/Assets/chocopoi/DressingTools/Translations/en.json @@ -40,6 +40,7 @@ "radio_db_remove_and_parent_const": "Remove and use parent constraints pointing to avatar for all clothes bones (Preferred)", "radio_db_keep_clothes_and_parent_const_if_need": "Keep clothes dynamic bones and use parent constraints if necessary", "radio_db_create_child_and_exclude": "Create GameObject child and exclude it from DynamicBone (Legacy)", + "radio_db_copy_dyn_bone_to_clothes": "Copy DynamicBones to clothes (Legacy)", "radio_db_ignore_all": "Ignore all", "label_check_and_dress": "Check and Dress up", @@ -77,7 +78,10 @@ "helpbox_info_existing_prefix_detected_not_removed": "Info: Existing prefix is detected but not removed in some bones. Try enabling the setting if you experience bone mismatch problems.", "helpbox_info_existing_suffix_detected_and_removed": "Info: Existing suffix is detected and removed in some bones. Try disabling the setting if you experience bone mismatch problems.", "helpbox_info_existing_suffix_detected_not_removed": "Info: Existing suffix is detected but not removed in some bones. Try enabling the setting if you experience bone mismatch problems.", + "helpbox_info_armature_object_guessed": "Info: The clothes armature was guessed. If the guessed armature is incorrect, please rename the correct armature with the name \"Armature\".", + "helpbox_info_multiple_bones_in_clothes_armature_first_level_warning_removed": "Info: Multiple bones detected in the first level of avatar armature.", + "helpbox_info_dyn_bone_config_details": "For details what the configuration actually means:", "helpbox_info_move_clothes_into_place": "Remember to move your clothes into place before dressing up! This tool only combines but cannot put it into place currently.", "helpbox_warn_exit_play_mode": "Please exit play mode to continue!", "dialog_test_mode_not_implemented": "Testing is currently not implemented. Please test it manually by moving the bones of DressingToolsPreview in Play Mode." diff --git a/Assets/chocopoi/DressingTools/Translations/fr.json b/Assets/chocopoi/DressingTools/Translations/fr.json index 60dc4a74..d677a886 100644 --- a/Assets/chocopoi/DressingTools/Translations/fr.json +++ b/Assets/chocopoi/DressingTools/Translations/fr.json @@ -40,6 +40,7 @@ "radio_db_remove_and_parent_const": "Supprimer et utiliser des contraintes pointant vers l'armature de l'avatar (Recommandé)", "radio_db_keep_clothes_and_parent_const_if_need": "Conserver les Dynamic Bones et utiliser des contraintes si nécéssaire", "radio_db_create_child_and_exclude": "Créer un enfant GameObject et l'exclure du Dynamic Bone (Legacy)", + "radio_db_copy_dyn_bone_to_clothes": "Copier DynamicBones aux vêtements (Legacy)", "radio_db_ignore_all": "Tout ignorer", "label_check_and_dress": "Vérifier et habiller", @@ -77,7 +78,10 @@ "helpbox_info_existing_prefix_detected_not_removed": "Info: Un ou des préfixe ont été trouvés et ne seront pas supprimés. Essayez d'activer cette option si vous rencontrez des problèmes.", "helpbox_info_existing_suffix_detected_and_removed": "Info: Un ou des suffixes ont été trouvés et supprimés. Essayez de désactiver cette option si vous rencontrez des problèmes.", "helpbox_info_existing_suffix_detected_not_removed": "Info: Un ou des suffixes ont été trouvés et ne seront pas supprimés. Essayez d'activer cette option si vous rencontrez des problèmes.", + "helpbox_info_armature_object_guessed": "Info: on a deviné l'armure à vêtements. Si l'armure devinée est incorrecte, veuillez renommer l'armure correcte avec le nom \"Armature\".", + "helpbox_info_multiple_bones_in_clothes_armature_first_level_warning_removed": "Info: Plusieurs os détectés à la racine de l'armature de l'avatar.", + "helpbox_info_dyn_bone_config_details": "Pour plus de détails, voir ce que signifie réellement la configuration: ", "helpbox_info_move_clothes_into_place": "Déplacez votre costume au bon endroit avant de continuer! Cet outil peut combiner mais pas encore déplacer.", "helpbox_warn_exit_play_mode": "Veuillez fermer le Play Mode avant de continuer!", "dialog_test_mode_not_implemented": "Le mode test n'est pas encore implémenté. Veuillez tester manuellement en déplaçant les os de DressingToolsPreview en Play Mode." diff --git a/Assets/chocopoi/DressingTools/Translations/jp.json b/Assets/chocopoi/DressingTools/Translations/jp.json index d0816ed6..5a7e1e7d 100644 --- a/Assets/chocopoi/DressingTools/Translations/jp.json +++ b/Assets/chocopoi/DressingTools/Translations/jp.json @@ -39,7 +39,8 @@ "label_dynamic_bone_if_in_avatar_bone": "アバターの骨と服の骨の両方にDynamicBoneがあるなら:", "radio_db_remove_and_parent_const": "服の骨DynamicBoneを削除してParentConstraintを使用してアバターの骨を指し示す(おすすめ)", "radio_db_keep_clothes_and_parent_const_if_need": "服の骨のDynamicBoneを維持し、必要に応じてParentConstraintを使用", - "radio_db_create_child_and_exclude": "新しいアバターの骨を作成し、アバターのDynamicBoneから除外する (古い方法)", + "radio_db_create_child_and_exclude": "新しいアバターの骨を作成し、アバターのDynamicBoneから除外する (旧方法)", + "radio_db_copy_dyn_bone_to_clothes": "アバターのDynamicBoneを衣服にコピーする (旧方法)", "radio_db_ignore_all": "全てを無視する", "label_check_and_dress": "チェックと服を着せる", @@ -77,7 +78,10 @@ "helpbox_info_existing_prefix_detected_not_removed": "お知らせ: いくつかの服の骨から既存のプレフィックスが発見されたが、削除されなかった、もし服の骨が一致する問題が発生したら、その設定を試してみてください。", "helpbox_info_existing_suffix_detected_and_removed": "お知らせ: いくつかの服の骨から既存のサフィックスが発見されたが、削除されなかった、もし服の骨が一致する問題が発生したら、その設定を試してみてください。", "helpbox_info_existing_suffix_detected_not_removed": "お知らせ: いくつかの服の骨から既存のサフィックスが発見されたが、削除されなかった、もし服の骨が一致する問題が発生したら、その設定を試してみてください。", + "helpbox_info_armature_object_guessed": "お知らせ: 服のArmatureは推測です。 正しくない場合は、正しいArmatureの名前を \"Armature\" に変更してください。", + "helpbox_info_multiple_bones_in_clothes_armature_first_level_warning_removed": "お知らせ: アバターのArmatureの第1段階で複数の骨が見つかりました", + "helpbox_info_dyn_bone_config_details": "DynamicBoneの設定の詳細:", "helpbox_info_move_clothes_into_place": "着る前に自分の服をよく置きなさい、このツールはアバターと服を自動的に合わせるだけで、服の位置を自動的に調整することはできません。", "helpbox_warn_exit_play_mode": "Play Modeを終了して続行してください!", "dialog_test_mode_not_implemented": "現在はテストモードがありません、PlayModeでDressingToolsPreview_{0}のアバターの骨を動かして手動で服をテストしてください。" diff --git a/Assets/chocopoi/DressingTools/Translations/kr.json b/Assets/chocopoi/DressingTools/Translations/kr.json index 5ccfb270..d1b3ec29 100644 --- a/Assets/chocopoi/DressingTools/Translations/kr.json +++ b/Assets/chocopoi/DressingTools/Translations/kr.json @@ -38,7 +38,8 @@ "label_dynamic_bone_if_in_avatar_bone": "아바타 뼈와 옷 뼈 모두에 다이나믹본이 있다면:", "radio_db_remove_and_parent_const": "옷bone Dynamic Bone을 삭제하고 Parent Constraint를 사용하여 아바타 bone을 가리킴 (권장)", "radio_db_keep_clothes_and_parent_const_if_need": "옷 bone의 Dynamic Bone 유지 및 필요시 Parent Constraint 사용", - "radio_db_create_child_and_exclude": "새로운 아바타 bone을 생성하여 아바타의 Dynamic Bone에서 제외 (오래된 방법)", + "radio_db_create_child_and_exclude": "새로운 아바타 bone을 생성하여 아바타의 Dynamic Bone에서 제외 (구방법)", + "radio_db_copy_dyn_bone_to_clothes": "아바타의 DynamicBone을 복사하기 (구방법)", "radio_db_ignore_all": "모두 무시", "label_check_and_dress": "확인 및 옷입히기", @@ -76,7 +77,10 @@ "helpbox_info_existing_prefix_detected_not_removed": "정보: 몇 개의 clothes의 bone에서 기존의 prefix가 발견되었지만, 삭제되지 않았어요. 만약 clothes의 bone이 일치하는 문제가 발생하면, 그 설정을 시도해 보세요.", "helpbox_info_existing_suffix_detected_and_removed": "정보: 몇 개의 clothes의 bone에서 기존의 surfix가 발견되어 삭제되었어요. 만약 clothes의 bone가 일치하는 문제가 발생하면, 그 설정을 지워 보세요", "helpbox_info_existing_suffix_detected_not_removed": "정보: 몇 개의 clothes의 bone에서 기존의 surfix가 발견되었지만, 삭제되지 않았어요. 만약 clothes의 bone이 일치하는 문제가 발생하면, 그 설정을 시도해 보세요.", + "helpbox_info_armature_object_guessed": "경고: 옷의 Armature는 확실하지 않아요. 올바르지 않으면 올바르게 Armature로 변경하세요", + "helpbox_info_multiple_bones_in_clothes_armature_first_level_warning_removed": "정보: 아바타의 Armature 밑에서 여러 개의 bone이 발견되었어요.", + "helpbox_info_dyn_bone_config_details": "DynamicBone 설정 세부 사항: ", "helpbox_info_move_clothes_into_place": "입히기 전에 자신의 옷을 잘 맞춰주세요, 이 도구는 아바타와 옷을 자동적으로 맞추는 것만으로 옷의 위치를 자동으로 조정할 수 없어요", "helpbox_warn_exit_play_mode": "계속하려면 play mode를 종료해주세요", "dialog_test_mode_not_implemented": "테스트가 현재 구현되지 않았습니다. 위에 재생을 누르고 DressingToolsPreview의 아바타 bone을 이동하여 수동으로 테스트하십시오." diff --git a/Assets/chocopoi/DressingTools/Translations/zh.json b/Assets/chocopoi/DressingTools/Translations/zh.json index edfb6614..97e3cb1b 100644 --- a/Assets/chocopoi/DressingTools/Translations/zh.json +++ b/Assets/chocopoi/DressingTools/Translations/zh.json @@ -40,6 +40,7 @@ "radio_db_remove_and_parent_const": "刪除衣服骨頭DynamicBone並使用ParentConstraint指向角色骨頭 (推薦)", "radio_db_keep_clothes_and_parent_const_if_need": "保持衣服骨頭DynamicBone並有需要時使用ParentConstraint", "radio_db_create_child_and_exclude": "創建角色骨頭子GameObject並將其從角色骨頭DynamicBone中排除掉 (舊方法)", + "radio_db_copy_dyn_bone_to_clothes": "複製角色 DynamicBone 到衣服上 (舊方法)", "radio_db_ignore_all": "忽略所有", "label_check_and_dress": "檢查和打扮", @@ -77,7 +78,10 @@ "helpbox_info_existing_prefix_detected_not_removed": "通知: 有些衣服骨頭中發現到現有的前綴但沒有被刪除, 如果你遇到衣服骨頭匹配問題, 請嘗試打開那個設定", "helpbox_info_existing_suffix_detected_and_removed": "通知: 有些衣服骨頭中發現到現有的後綴並已刪除, 如果你遇到衣服骨頭匹配問題, 請嘗試關掉那個設定", "helpbox_info_existing_suffix_detected_not_removed": "通知: 有些衣服骨頭中發現到現有的後綴但沒有被刪除, 如果你遇到衣服骨頭匹配問題, 請嘗試打開那個設定", + "helpbox_info_armature_object_guessed": "通知: 衣服骨架是猜出來的。 如果猜出來的骨架不正確,請自已把正確的骨架重命名為 \"Armature\"", + "helpbox_info_multiple_bones_in_clothes_armature_first_level_warning_removed": "通知: 在角色骨架的第一級中發現到多個骨頭", + "helpbox_info_dyn_bone_config_details": "有關 DynamicBone 設定的詳細:", "helpbox_info_move_clothes_into_place": "記得在穿着之前把你的衣服放好, 目前這個工具只能自動合拼角色和衣服,但不能自動調整衣服位置。", "helpbox_warn_exit_play_mode": "請退出Play Mode以繼續!", "dialog_test_mode_not_implemented": "暫時未有測試模式。 請用Play Mode移動 DressingToolsPreview_{0} 的角色骨頭來手動測試衣服。" diff --git a/Assets/chocopoi/DressingTools/version.txt b/Assets/chocopoi/DressingTools/version.txt index afaf360d..7f207341 100644 --- a/Assets/chocopoi/DressingTools/version.txt +++ b/Assets/chocopoi/DressingTools/version.txt @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.0.1 \ No newline at end of file