From 5911973e9d1d6660ed5e2d384801c6f0b52c7fc6 Mon Sep 17 00:00:00 2001 From: bd_ Date: Fri, 9 Dec 2022 11:40:00 -0800 Subject: [PATCH] Enable (but no-op) setup outfit when outfit is already setup (#148) Closes: #132 --- .../nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs b/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs index 12dec868..5722841f 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs @@ -18,6 +18,8 @@ namespace nadena.dev.modular_avatar.core.editor var avatarArmature = avatarHips.transform.parent; var outfitArmature = outfitHips.transform.parent; + if (outfitArmature.GetComponent() != null) return; + var merge = Undo.AddComponent(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() != null) + if (!FindBones(obj, out var _, out var _, out var outfitHips)) { return false; }