Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Editor/Localization/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@
"ma_info.param_usage_ui.free_space": "Unused parameter space ({0} bits)",
"ma_info.param_usage_ui.exceeded_space": "Excess parameters ({0} bits)",
"ma_info.param_usage_ui.bits_template": "{0} ({1} bits)",
"ma_info.param_usege_ui.parameter_type": "type : {0} ({1} bits)",
"ma_info.param_usage_ui.is_name_deferred": "Auto rename : {0}",
"ma_info.param_usage_ui.no_data": "[ NO DATA ]",
"reactive_object.inverse": "Inverse Condition",
"reactive_object.mesh_cutter.object": "Target Renderer",
Expand Down
2 changes: 2 additions & 0 deletions Editor/Localization/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@
"ma_info.param_usage_ui.free_space": "未使用領域 ({0} 個のビット)",
"ma_info.param_usage_ui.exceeded_space": "超過分 ({0} 個のビット)",
"ma_info.param_usage_ui.bits_template": "{0} ({1} 個のビットを使用中)",
"ma_info.param_usege_ui.parameter_type": "タイプ : {0} ({1} ビット)",
"ma_info.param_usage_ui.is_name_deferred": "自動リネーム : {0}",
"ma_info.param_usage_ui.no_data": "[ NO DATA ]",
"reactive_object.inverse": "条件を反転",
"reactive_object.mesh_cutter.object": "対象のレンダラー",
Expand Down
2 changes: 2 additions & 0 deletions Editor/Localization/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@
"ma_info.param_usage_ui.free_space": "사용 가능 영역 ({0} 비트)",
"ma_info.param_usage_ui.exceeded_space": "초과 영역 ({0} 비트)",
"ma_info.param_usage_ui.bits_template": "{0} ({1} 비트 사용 중)",
"ma_info.param_usege_ui.parameter_type": "type : {0} ({1} bits)",
"ma_info.param_usage_ui.is_name_deferred": "Auto rename : {0}",
"ma_info.param_usage_ui.no_data": "[ 데이터 없음 ]",
"reactive_object.inverse": "조건 반전",
"reactive_object.mesh_cutter.object": "대상 렌더러",
Expand Down
2 changes: 2 additions & 0 deletions Editor/Localization/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@
"ma_info.param_usage_ui.other_objects": "此 Avatar 中的其他东西",
"ma_info.param_usage_ui.free_space": "未使用的参数 ({0} bits)",
"ma_info.param_usage_ui.bits_template": "{0} ({1} bits)",
"ma_info.param_usege_ui.parameter_type": "type : {0} ({1} bits)",
"ma_info.param_usage_ui.is_name_deferred": "Auto rename : {0}",
"ma_info.param_usage_ui.no_data": "【无信息】",
"reactive_object.inverse": "反转条件",
"reactive_object.delete-mesh-by-mask.material-index": "材质槽",
Expand Down
2 changes: 2 additions & 0 deletions Editor/Localization/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@
"ma_info.param_usage_ui.free_space": "未使用的參數空間 ({0} bits)",
"ma_info.param_usage_ui.exceeded_space": "額外參數({0} bits)",
"ma_info.param_usage_ui.bits_template": "{0} ({1} bits)",
"ma_info.param_usege_ui.parameter_type": "type : {0} ({1} bits)",
"ma_info.param_usage_ui.is_name_deferred": "Auto rename : {0}",
"ma_info.param_usage_ui.no_data": "【無資訊】",
"reactive_object.inverse": "反轉條件",
"reactive_object.mesh_cutter.object": "目標 Renderer",
Expand Down
5 changes: 3 additions & 2 deletions Editor/ParamsUsage/MAParametersIntrospection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public IEnumerable<ProvidedParameter> GetSuppliedParameters(ndmf.BuildContext co

var hidden = false;
var name = _component.Control?.parameter?.name;
var isAutoName = string.IsNullOrWhiteSpace(name);
if (string.IsNullOrWhiteSpace(name))
{
name = $"__MA/AutoParam/{_component.gameObject.name}${_component.GetInstanceID()}";
Expand All @@ -37,7 +38,7 @@ public IEnumerable<ProvidedParameter> GetSuppliedParameters(ndmf.BuildContext co
yield return new ProvidedParameter(
name,
ParameterNamespace.Animator,
_component, PluginDefinition.Instance, _component.AnimatorControllerParameterType)
_component, PluginDefinition.Instance, _component.AnimatorControllerParameterType, isAutoName)
{
ExpandTypeOnConflict = true,
WantSynced = _component.isSynced,
Expand Down Expand Up @@ -85,7 +86,7 @@ public IEnumerable<ProvidedParameter> GetSuppliedParameters(ndmf.BuildContext co
return new ProvidedParameter(
p.nameOrPrefix,
p.isPrefix ? ParameterNamespace.PhysBonesPrefix : ParameterNamespace.Animator,
_component, PluginDefinition.Instance, paramType)
_component, PluginDefinition.Instance, paramType, p.internalParameter)
{
IsAnimatorOnly = animatorOnly,
WantSynced = !p.localOnly && !animatorOnly,
Expand Down
33 changes: 33 additions & 0 deletions Editor/ParamsUsage/ParamsUsage.uss
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@
margin-bottom: 12px;
}

LogoImage {
flex-shrink: 0;
}

#Footer {
margin-left: 15px;
margin-right: 15px;
flex-shrink: 0;
}

#UsageBox {
height: 16px;
flex-direction: row;
margin-bottom: 8px;
flex-shrink: 0;
}

#UsageBox VisualElement {
Expand All @@ -52,6 +58,33 @@
flex-direction: row;
}

.Entry .ParameterFoldout {
flex-grow: 1;
}

.Entry .ParameterFoldout .unity-foldout__toggle {
margin: 0;
}

.Entry .ParameterFoldout .unity-foldout__toggle .unity-foldout__text {
padding-top: 0;
margin-left: 0;
}

.Entry .ParameterFoldout .ParameterBox {
padding: 5px;
flex-direction: column;
align-items: flex-start;
}

.Entry .ParameterFoldout .ParameterBox .ParameterName {
-unity-font-style: bold;
}

.Entry .ParameterFoldout .ParameterBox .ParameterDetails {
margin-left: 5px;
}

.IconOuter {
border-top-width: 3px;
border-bottom-width: 3px;
Expand Down
4 changes: 2 additions & 2 deletions Editor/ParamsUsage/ParamsUsage.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ui:VisualElement name="UnusedSpace" style="width: auto; background-color: #eeeeee; flex-grow: 1;"/>
</ui:VisualElement>

<ui:VisualElement name="Legend">
<ui:ScrollView name="Legend">
<ui:VisualElement class="retained">
<ui:VisualElement class="Entry" name="OtherObjects" style="display: none">
<ui:VisualElement class="IconOuter">
Expand All @@ -31,7 +31,7 @@
</ui:VisualElement>
</ui:VisualElement>

</ui:VisualElement>
</ui:ScrollView>

<ui:VisualElement name="Exceeded">
</ui:VisualElement>
Expand Down
74 changes: 57 additions & 17 deletions Editor/ParamsUsage/ParamsUsageWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using nadena.dev.modular_avatar.ui;
using nadena.dev.ndmf;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
using VRC.SDK3.Avatars.ScriptableObjects;
Expand Down Expand Up @@ -181,16 +182,22 @@ private void Recalculate()
{
outerbox.RemoveFromClassList("no-data");
}

var parameters = ParameterInfo.ForUI.GetParametersForObject(target)
.Where(p => p.BitUsage > 0)
.ToArray();

var orderedPlugins = ParameterInfo.ForUI.GetParametersForObject(target)
var orderedPlugins = parameters
.GroupBy(p => p.Plugin)
.Select(group => (group.Key, group.Sum(p => p.BitUsage)))
.Where((kv, index) => kv.Item2 > 0)
.OrderBy(group => group.Key.DisplayName)
.ToList();

var parameterLookup = parameters
.ToLookup(p => p.Plugin);

var byPlugin = orderedPlugins
.Zip(Colors(), (kv, color) => (kv.Key.DisplayName, kv.Item2, kv.Key.ThemeColor ?? color))
.Zip(Colors(), (kv, color) => (kv.Key.DisplayName, kv.Item2, kv.Key.ThemeColor ?? color, parameterLookup[kv.Key]))
.ToList();

int totalUsage = byPlugin.Sum(kv => kv.Item2);
Expand All @@ -206,32 +213,32 @@ private void Recalculate()
if (avatarTotalUsage > totalUsage)
{
byPlugin.Add((Localization.S("ma_info.param_usage_ui.other_objects"), avatarTotalUsage - totalUsage,
Color.gray));
Color.gray, null));
}

var bits_template = Localization.S("ma_info.param_usage_ui.bits_template");
byPlugin = byPlugin.Select((tuple, _) =>
(string.Format(bits_template, tuple.Item1, tuple.Item2), tuple.Item2, tuple.Item3)).ToList();
(string.Format(bits_template, tuple.Item1, tuple.Item2), tuple.Item2, tuple.Item3, tuple.Item4)).ToList();

if (freeSpace > 0)
{
var free_space_label = Localization.S("ma_info.param_usage_ui.free_space");
byPlugin.Add((string.Format(free_space_label, freeSpace), freeSpace, Color.white));
byPlugin.Add((string.Format(free_space_label, freeSpace), freeSpace, Color.white, null));
}

if (freeSpace < 0)
if (freeSpace < 0)
{
outerbox.AddToClassList("exceeded");
var exceeded = _root.Q<VisualElement>("Exceeded");
outerbox.AddToClassList("exceeded");
var exceeded = _root.Q<VisualElement>("Exceeded");
exceeded.Clear();
var exceededLabel = new Label();
var exceeded_space_label = Localization.S("ma_info.param_usage_ui.exceeded_space");
exceededLabel.text = string.Format(exceeded_space_label, freeSpace);
exceeded.Add(exceededLabel);
exceeded.Add(exceededLabel);
}
else
else
{
outerbox.RemoveFromClassList("exceeded");
outerbox.RemoveFromClassList("exceeded");
}

foreach (var child in _legendContainer.Children().ToList())
Expand All @@ -243,8 +250,11 @@ private void Recalculate()
{
child.RemoveFromHierarchy();
}

foreach (var (label, usage, color) in byPlugin)

var parameter_type_template = Localization.S("ma_info.param_usege_ui.parameter_type");
var parameter_is_name_deferred_template = Localization.S("ma_info.param_usage_ui.is_name_deferred");

foreach (var (label, usage, color, providedParameters) in byPlugin)
{
var colorBar = new VisualElement();
colorBar.style.backgroundColor = color;
Expand All @@ -266,9 +276,39 @@ private void Recalculate()
icon_outer.Add(icon_inner);
icon_inner.style.backgroundColor = color;

var pluginLabel = new Label(label);
entry.Add(pluginLabel);

if (providedParameters != null) {
var pluginFoldout = new Foldout {
text = label,
value = false
};

pluginFoldout.AddToClassList("ParameterFoldout");

foreach (ProvidedParameter providedParameter in providedParameters) {
var box = new Box();
box.AddToClassList("ParameterBox");
box.AddToClassList("unity-help-box");
pluginFoldout.Add(box);

var parameterNameLabel = new Label(providedParameter.EffectiveName);
parameterNameLabel.AddToClassList("ParameterName");
box.Add(parameterNameLabel);

var details = new VisualElement();
details.AddToClassList("ParameterDetails");
box.Add(details);
var sourceField = new ObjectField {value = providedParameter.Source};
sourceField.SetEnabled(false);
details.Add(sourceField);
details.Add(new Label(string.Format(parameter_type_template, providedParameter.ParameterType, providedParameter.BitUsage)));
details.Add(new Label(string.Format(parameter_is_name_deferred_template, providedParameter.IsNameDeferred)));

@bdunderscore bdunderscore Jun 21, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsNameDeferredの取り扱いはちょっと思想が曖昧ですね…

まず、二つのパラメーターが統合されているかどうかは、このboolだけでは判定できない(MA Parametersの自動リネームだと仮定すれば、Sourceで推測できるが、「IsModularAvatarAutoRename」ではないためその仮定が必ずしもあっているとは限らない)
また、他のアセットのDeferredなパラメーターを自動リネームと称するべきではない。

まずはいったん、この情報の表示が必要かを精査しましょう。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうですね
こちらの表示意図としては、
ビルド後にパラメータ名が、表示されているものから変わるというのを分かるようにしたいため、
'IsModularAvatarAutoRename' : 自動リネーム

'IsUnconfirmedName' : 未確定な名前
など別で持たせるとかでしょうか

}
entry.Add(pluginFoldout);
} else {
var pluginLabel = new Label(label);
entry.Add(pluginLabel);
}

entry.style.borderBottomColor = color;
entry.style.borderTopColor = color;
entry.style.borderLeftColor = color;
Expand Down
Loading