Skip to content

Commit

Permalink
Merge pull request #1 from poi-vrc/develop
Browse files Browse the repository at this point in the history
DressingTools 1.0.1 Patch
  • Loading branch information
poi-vrc authored Feb 22, 2022
2 parents 372568e + cbae39a commit 0b2ae11
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Assets/chocopoi/DressingTools/Editor/DressCheckCodeMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
21 changes: 20 additions & 1 deletion Assets/chocopoi/DressingTools/Editor/DressingToolsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
53 changes: 47 additions & 6 deletions Assets/chocopoi/DressingTools/Editor/Rules/ArmatureRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level,
// Find whether there is a DynamicBone component in the bone

DynamicBone avatarDynBone = avatarTrans?.GetComponent<DynamicBone>();
DynamicBone childDynBone = child?.GetComponent<DynamicBone>();
DynamicBone childDynBone = child.GetComponent<DynamicBone>();

if (avatarDynBone != null || childDynBone != null)
{
if (settings.dynamicBoneOption == 0) //remove and use parent constraints
{
if (avatarDynBone != null)
{
Object.DestroyImmediate(childDynBone);
if (childDynBone != null)
{
Object.DestroyImmediate(childDynBone);
}

ParentConstraint comp = child.gameObject.AddComponent<ParentConstraint>();
comp.constraintActive = true;
Expand All @@ -61,7 +64,7 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level,
{
if (childDynBone == null)
{
ParentConstraint comp = childDynBone.gameObject.AddComponent<ParentConstraint>();
ParentConstraint comp = child.gameObject.AddComponent<ParentConstraint>();
comp.constraintActive = true;

ConstraintSource source = new ConstraintSource
Expand Down Expand Up @@ -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;
Expand All @@ -116,7 +136,7 @@ private bool ProcessBone(DressReport report, DressSettings settings, int level,
}

if (!ProcessBone(report, settings, level + 1, avatarTrans, child))
{
{
return false;
}
}
Expand All @@ -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");
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,47 @@ public void ProcessBone(DressReport report, DressSettings settings, Transform bo
}
}

public Transform GuessArmature(GameObject targetClothes)
{
List<Transform> transforms = new List<Transform>();

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);
Expand Down
4 changes: 4 additions & 0 deletions Assets/chocopoi/DressingTools/Editor/TranslationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Assets/chocopoi/DressingTools/Translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand 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."
Expand Down
4 changes: 4 additions & 0 deletions Assets/chocopoi/DressingTools/Translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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."
Expand Down
6 changes: 5 additions & 1 deletion Assets/chocopoi/DressingTools/Translations/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "チェックと服を着せる",
Expand Down Expand Up @@ -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}のアバターの骨を動かして手動で服をテストしてください。"
Expand Down
Loading

0 comments on commit 0b2ae11

Please sign in to comment.