From 4c6b41de4c92da5828219657b2927c90685e275a Mon Sep 17 00:00:00 2001 From: nekobako Date: Thu, 19 Sep 2024 02:44:49 +0900 Subject: [PATCH] fix: resolve parameter type conflicts for menu items in params usage window --- Editor/ParamsUsage/ParamsUsageWindow.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Editor/ParamsUsage/ParamsUsageWindow.cs b/Editor/ParamsUsage/ParamsUsageWindow.cs index 4d8f58ee..40ae45ff 100644 --- a/Editor/ParamsUsage/ParamsUsageWindow.cs +++ b/Editor/ParamsUsage/ParamsUsageWindow.cs @@ -182,7 +182,22 @@ namespace nadena.dev.modular_avatar.core.editor outerbox.RemoveFromClassList("no-data"); } - var orderedPlugins = ParameterInfo.ForUI.GetParametersForObject(target) + ParameterInfo.ConflictHandler onConflict = (type, p1, p2) => + { + if (p1.Source is not ModularAvatarMenuItem || + p2.Source is not ModularAvatarMenuItem) + { + return; + } + + if (p1.ParameterType == AnimatorControllerParameterType.Bool || + p2.ParameterType == AnimatorControllerParameterType.Float) + { + p1.ParameterType = p2.ParameterType; + } + }; + + var orderedPlugins = ParameterInfo.ForUI.GetParametersForObject(target, onConflict) .GroupBy(p => p.Plugin) .Select(group => (group.Key, group.Sum(p => p.BitUsage))) .Where((kv, index) => kv.Item2 > 0) @@ -196,7 +211,7 @@ namespace nadena.dev.modular_avatar.core.editor int totalUsage = byPlugin.Sum(kv => kv.Item2); int avatarTotalUsage = - ParameterInfo.ForUI.GetParametersForObject(avatarRoot).Sum(p => p.BitUsage); + ParameterInfo.ForUI.GetParametersForObject(avatarRoot, onConflict).Sum(p => p.BitUsage); int freeSpace = VRCExpressionParameters.MAX_PARAMETER_COST - avatarTotalUsage;