From 38be43163fb32d9ec0683a3d8485525429b63818 Mon Sep 17 00:00:00 2001 From: tliks Date: Sat, 15 Mar 2025 11:50:38 +0900 Subject: [PATCH] chore: use simple suffixes --- Editor/Inspector/Menu/ToggleCreatorShortcut.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Editor/Inspector/Menu/ToggleCreatorShortcut.cs b/Editor/Inspector/Menu/ToggleCreatorShortcut.cs index 04eda66b..8484fcdf 100644 --- a/Editor/Inspector/Menu/ToggleCreatorShortcut.cs +++ b/Editor/Inspector/Menu/ToggleCreatorShortcut.cs @@ -72,19 +72,19 @@ namespace nadena.dev.modular_avatar.core.editor if (targetSubMenu != null) // If target SubMenu is found, add the toggles as children of it. { parent = targetSubMenu.gameObject; - CreateToggleImpl(targets, parent, s => s.name, forSelection, createInstaller:false); + CreateToggleImpl(targets, parent, forSelection, createInstaller:false); } else { if (targets.Count() > 1) // Create a submenu and add the toggles as children of it. { parent = CreateSubMenu(parent, subMenuName).gameObject; - CreateToggleImpl(targets, parent, s => s.name, forSelection, createInstaller:false); + CreateToggleImpl(targets, parent, forSelection, createInstaller:false); } else // Create a single toggle with installer. { var target = targets.First(); - CreateToggleImpl(target, parent, target.name + " Toggle", forSelection, createInstaller:true); + CreateToggleImpl(target, parent, forSelection, createInstaller:true); } } } @@ -112,7 +112,7 @@ namespace nadena.dev.modular_avatar.core.editor createInstaller = false; } - CreateToggleImpl(selected, parent, "New Toggle", createInstaller:createInstaller); + CreateToggleImpl(selected, parent, createInstaller:createInstaller); } Selection.objects = null; @@ -161,18 +161,21 @@ namespace nadena.dev.modular_avatar.core.editor return mami; } - private static void CreateToggleImpl(IEnumerable selections, GameObject parent, Func nameFunc, bool forSelection = false, bool createInstaller = true) + private static void CreateToggleImpl(IEnumerable selections, GameObject parent, bool forSelection = false, bool createInstaller = true) { foreach (var selected in selections) { - CreateToggleImpl(selected, parent, nameFunc(selected), forSelection, createInstaller); + CreateToggleImpl(selected, parent, forSelection, createInstaller); } } - private static void CreateToggleImpl(GameObject selected, GameObject parent, string name, bool forSelection = false, bool createInstaller = true) + private static void CreateToggleImpl(GameObject selected, GameObject parent, bool forSelection = false, bool createInstaller = true) { var avatarRoot = RuntimeUtil.FindAvatarTransformInParents(selected.transform); if (avatarRoot == null) return; + + var suffix = selected.activeSelf ? "OFF" : "ON"; + var name = forSelection ? $"{selected.name} {suffix}" : "New Toggle"; var toggle = new GameObject(name);