diff --git a/Editor/EasySetupOutfit.cs b/Editor/EasySetupOutfit.cs index e73b268c..dd73a749 100644 --- a/Editor/EasySetupOutfit.cs +++ b/Editor/EasySetupOutfit.cs @@ -302,7 +302,7 @@ namespace nadena.dev.modular_avatar.core.editor return true; } - private static bool FindBones(Object obj, out GameObject avatarRoot, out GameObject avatarHips, + internal static bool FindBones(Object obj, out GameObject avatarRoot, out GameObject avatarHips, out GameObject outfitHips) { avatarHips = outfitHips = null; @@ -361,8 +361,12 @@ namespace nadena.dev.modular_avatar.core.editor if (tempHip.name.Contains(avatarHips.name)) { outfitHips = tempHip.gameObject; + // Prefer the first hips we find + break; } } + + if (outfitHips != null) break; } hipsCandidates.Add(avatarHips.name); diff --git a/SetupUnitTests.ps1 b/SetupUnitTests.ps1 new file mode 100644 index 00000000..ed38ea39 --- /dev/null +++ b/SetupUnitTests.ps1 @@ -0,0 +1 @@ + new-item -itemtype symboliclink -value UnitTests~ -Path UnitTests \ No newline at end of file diff --git a/SetupUnitTests.ps1.meta b/SetupUnitTests.ps1.meta new file mode 100644 index 00000000..abfde939 --- /dev/null +++ b/SetupUnitTests.ps1.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: eda33529cf6a43e4c84f0ce4832a0800 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnitTests~/ArmatureConfusion.meta b/UnitTests~/EasySetupOutfit.meta similarity index 100% rename from UnitTests~/ArmatureConfusion.meta rename to UnitTests~/EasySetupOutfit.meta diff --git a/UnitTests~/ArmatureConfusion/ArmatureConfusionTest.cs b/UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs similarity index 100% rename from UnitTests~/ArmatureConfusion/ArmatureConfusionTest.cs rename to UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs diff --git a/UnitTests~/ArmatureConfusion/ArmatureConfusionTest.cs.meta b/UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs.meta similarity index 100% rename from UnitTests~/ArmatureConfusion/ArmatureConfusionTest.cs.meta rename to UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs.meta diff --git a/UnitTests~/EasySetupOutfit/PreferFirstHipsMatch.cs b/UnitTests~/EasySetupOutfit/PreferFirstHipsMatch.cs new file mode 100644 index 00000000..c0416e43 --- /dev/null +++ b/UnitTests~/EasySetupOutfit/PreferFirstHipsMatch.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using modular_avatar_tests; +using nadena.dev.modular_avatar.core.editor; +using NUnit.Framework; +using UnityEngine; +using VRC.SDK3.Avatars.Components; + +public class PreferFirstHipsMatch : TestBase +{ + [Test] + public void SetupHeuristicPrefersFirstHipsMatch() + { + var root = CreatePrefab("shapell.fbx"); + root.AddComponent(); + var root_hips = root.GetComponent().GetBoneTransform(HumanBodyBones.Hips).gameObject; + var root_armature = root_hips.transform.parent.gameObject; + var root_secondary = CreateChild(root, "PBC"); + var root_alt_hips = CreateChild(root_secondary, "Hips"); + + var outfit = CreateChild(root, "Outfit"); + var outfit_armature = CreateChild(outfit, "Armature"); + var outfit_hips = CreateChild(outfit_armature, "Hips"); + + Assert.IsTrue(EasySetupOutfit.FindBones(outfit, out var det_av_root, out var det_av_hips, out var det_outfit_hips)); + Assert.AreSame(root, det_av_root); + Assert.AreSame(root_hips, det_av_hips); + Assert.AreSame(outfit_hips, det_outfit_hips); + } +} \ No newline at end of file diff --git a/UnitTests~/EasySetupOutfit/PreferFirstHipsMatch.cs.meta b/UnitTests~/EasySetupOutfit/PreferFirstHipsMatch.cs.meta new file mode 100644 index 00000000..6ae56478 --- /dev/null +++ b/UnitTests~/EasySetupOutfit/PreferFirstHipsMatch.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9041d36a92ec4079804fb918c3a9b3d1 +timeCreated: 1699511111 \ No newline at end of file diff --git a/UnitTests~/ArmatureConfusion/README.md b/UnitTests~/EasySetupOutfit/README.md similarity index 100% rename from UnitTests~/ArmatureConfusion/README.md rename to UnitTests~/EasySetupOutfit/README.md diff --git a/UnitTests~/ArmatureConfusion/README.md.meta b/UnitTests~/EasySetupOutfit/README.md.meta similarity index 100% rename from UnitTests~/ArmatureConfusion/README.md.meta rename to UnitTests~/EasySetupOutfit/README.md.meta diff --git a/UnitTests~/ArmatureConfusion/material.mat b/UnitTests~/EasySetupOutfit/material.mat similarity index 100% rename from UnitTests~/ArmatureConfusion/material.mat rename to UnitTests~/EasySetupOutfit/material.mat diff --git a/UnitTests~/ArmatureConfusion/material.mat.meta b/UnitTests~/EasySetupOutfit/material.mat.meta similarity index 100% rename from UnitTests~/ArmatureConfusion/material.mat.meta rename to UnitTests~/EasySetupOutfit/material.mat.meta diff --git a/UnitTests~/ArmatureConfusion/shapell.fbx b/UnitTests~/EasySetupOutfit/shapell.fbx similarity index 100% rename from UnitTests~/ArmatureConfusion/shapell.fbx rename to UnitTests~/EasySetupOutfit/shapell.fbx diff --git a/UnitTests~/ArmatureConfusion/shapell.fbx.meta b/UnitTests~/EasySetupOutfit/shapell.fbx.meta similarity index 100% rename from UnitTests~/ArmatureConfusion/shapell.fbx.meta rename to UnitTests~/EasySetupOutfit/shapell.fbx.meta