mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 20:25:07 +08:00
feat: support multiple selections
This commit is contained in:
parent
11da8cd639
commit
492edb64fa
@ -9,16 +9,23 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
internal static class ToggleCreatorShortcut
|
internal static class ToggleCreatorShortcut
|
||||||
{
|
{
|
||||||
[MenuItem(UnityMenuItems.GameObject_SetupToggle, false, UnityMenuItems.GameObject_SetupToggleOrder)]
|
[MenuItem(UnityMenuItems.GameObject_SetupToggle, false, UnityMenuItems.GameObject_SetupToggleOrder)]
|
||||||
private static void SetupToggle() => CreateToggleImpl(true);
|
private static void SetupToggle() => CreateToggles(true);
|
||||||
|
|
||||||
[MenuItem(UnityMenuItems.GameObject_CreateToggle, false, UnityMenuItems.GameObject_CreateToggleOrder)]
|
[MenuItem(UnityMenuItems.GameObject_CreateToggle, false, UnityMenuItems.GameObject_CreateToggleOrder)]
|
||||||
private static void CreateToggle() => CreateToggleImpl(false);
|
private static void CreateToggle() => CreateToggles(false);
|
||||||
|
|
||||||
private static void CreateToggleImpl(bool setup)
|
private static void CreateToggles(bool setup)
|
||||||
|
{
|
||||||
|
var selections = Selection.objects;
|
||||||
|
foreach (var selection in selections) {
|
||||||
|
if (selection == null) continue;
|
||||||
|
CreateToggleImpl(selection as GameObject, setup);
|
||||||
|
}
|
||||||
|
Selection.objects = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateToggleImpl(GameObject selected, bool setup)
|
||||||
{
|
{
|
||||||
var selected = Selection.activeGameObject;
|
|
||||||
if (selected == null) return;
|
|
||||||
|
|
||||||
var avatarRoot = RuntimeUtil.FindAvatarTransformInParents(selected.transform);
|
var avatarRoot = RuntimeUtil.FindAvatarTransformInParents(selected.transform);
|
||||||
if (avatarRoot == null) return;
|
if (avatarRoot == null) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user