Enable (but no-op) setup outfit when outfit is already setup (#148)

Closes: #132
This commit is contained in:
bd_ 2022-12-09 11:40:00 -08:00 committed by GitHub
parent 811c934f40
commit 5911973e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,8 @@ namespace nadena.dev.modular_avatar.core.editor
var avatarArmature = avatarHips.transform.parent;
var outfitArmature = outfitHips.transform.parent;
if (outfitArmature.GetComponent<ModularAvatarMergeArmature>() != null) return;
var merge = Undo.AddComponent<ModularAvatarMergeArmature>(outfitArmature.gameObject);
merge.mergeTarget = new AvatarObjectReference();
merge.mergeTarget.referencePath = RuntimeUtil.RelativePath(avatarRoot, avatarArmature.gameObject);
@ -27,13 +29,14 @@ namespace nadena.dev.modular_avatar.core.editor
[MenuItem("GameObject/[ModularAvatar] Setup Outfit", true, PRIORITY)]
static bool ValidateSetupOutfit()
{
if (Selection.objects.Length == 0) return false;
foreach (var obj in Selection.objects)
{
if (!(obj is GameObject gameObj)) return false;
var xform = gameObj.transform;
if (!FindBones(obj, out var _, out var _, out var outfitHips)
|| outfitHips.transform.parent.GetComponent<ModularAvatarMergeArmature>() != null)
if (!FindBones(obj, out var _, out var _, out var outfitHips))
{
return false;
}