From d49f87e754879c252a5f91f15c30fe31ea7e8f75 Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 11 Aug 2024 18:09:20 -0700 Subject: [PATCH] ui: various MA Parameters UI adjustments (#984) * chore: use ON/OFF for parameters default field * ui: MA Parameters UI adjustments --- .../Inspector/Parameters/DefaultValueField.cs | 13 ++++++----- .../Parameters/ParameterConfigDrawer.cs | 22 +++++++++++++++++-- .../Parameters/ParameterConfigDrawer.uxml | 19 ++++++++++------ Editor/Inspector/Parameters/Parameters.uss | 17 ++++++++++++++ Editor/Localization/en-US.json | 5 +++-- Editor/Localization/ja-JP.json | 5 +++-- 6 files changed, 63 insertions(+), 18 deletions(-) diff --git a/Editor/Inspector/Parameters/DefaultValueField.cs b/Editor/Inspector/Parameters/DefaultValueField.cs index efa948f1..6cae5283 100644 --- a/Editor/Inspector/Parameters/DefaultValueField.cs +++ b/Editor/Inspector/Parameters/DefaultValueField.cs @@ -12,6 +12,9 @@ namespace nadena.dev.modular_avatar.core.editor { } + private const string V_True = "ON"; + private const string V_False = "OFF"; + private readonly TextField _visibleField; private readonly FloatField _defaultValueField; private readonly DropdownField _boolField; @@ -25,8 +28,8 @@ namespace nadena.dev.modular_avatar.core.editor _boolField = new DropdownField(); _boolField.choices.Add(""); - _boolField.choices.Add("True"); - _boolField.choices.Add("False"); + _boolField.choices.Add(V_True); + _boolField.choices.Add(V_False); _defaultValueField.RegisterValueChangedCallback( evt => UpdateVisibleField(evt.newValue, _hasExplicitDefaultSetField.value)); @@ -58,7 +61,7 @@ namespace nadena.dev.modular_avatar.core.editor _boolField.RegisterValueChangedCallback(evt => { - if (evt.newValue == "True") + if (evt.newValue == V_True) _defaultValueField.value = 1; else _defaultValueField.value = 0; @@ -95,9 +98,9 @@ namespace nadena.dev.modular_avatar.core.editor if (!hasExplicitValue) boolStr = ""; else if (value > 0.5) - boolStr = "True"; + boolStr = V_True; else - boolStr = "False"; + boolStr = V_False; _boolField.SetValueWithoutNotify(boolStr); } diff --git a/Editor/Inspector/Parameters/ParameterConfigDrawer.cs b/Editor/Inspector/Parameters/ParameterConfigDrawer.cs index e4afd0de..101716e2 100644 --- a/Editor/Inspector/Parameters/ParameterConfigDrawer.cs +++ b/Editor/Inspector/Parameters/ParameterConfigDrawer.cs @@ -20,14 +20,14 @@ namespace nadena.dev.modular_avatar.core.editor.Parameters Localization.UI.Localize(root); root.styleSheets.Add(uss); - // Prototype UI var proot = root.Q("Root"); var type_field = proot.Q("f-type"); + var f_sync_type = proot.Q("f-sync-type"); SetupPairedDropdownField( proot, type_field, - proot.Q("f-sync-type"), + f_sync_type, proot.Q("f-is-prefix"), ("Bool", "False", "params.syncmode.Bool"), ("Float", "False", "params.syncmode.Float"), @@ -36,6 +36,24 @@ namespace nadena.dev.modular_avatar.core.editor.Parameters (null, "True", "params.syncmode.PhysBonesPrefix") ); + f_sync_type.Q().RegisterValueChangedCallback(evt => + { + var is_anim_only = evt.newValue == "Not Synced"; + + if (is_anim_only) + proot.AddToClassList("st-anim-only"); + else + proot.RemoveFromClassList("st-anim-only"); + }); + + var f_synced = proot.Q("f-synced"); + var f_local_only = proot.Q("f-local-only"); + + // Invert f_local_only and f_synced + f_local_only.RegisterValueChangedCallback(evt => { f_synced.SetValueWithoutNotify(!evt.newValue); }); + + f_synced.RegisterValueChangedCallback(evt => { f_local_only.value = !evt.newValue; }); + var internalParamAccessor = proot.Q("f-internal-parameter"); internalParamAccessor.RegisterValueChangedCallback(evt => { diff --git a/Editor/Inspector/Parameters/ParameterConfigDrawer.uxml b/Editor/Inspector/Parameters/ParameterConfigDrawer.uxml index 8f0a246a..689abd89 100644 --- a/Editor/Inspector/Parameters/ParameterConfigDrawer.uxml +++ b/Editor/Inspector/Parameters/ParameterConfigDrawer.uxml @@ -24,18 +24,23 @@ - + - - + + + + + + + + - - - diff --git a/Editor/Inspector/Parameters/Parameters.uss b/Editor/Inspector/Parameters/Parameters.uss index a697c807..21042ac5 100644 --- a/Editor/Inspector/Parameters/Parameters.uss +++ b/Editor/Inspector/Parameters/Parameters.uss @@ -56,6 +56,7 @@ .horizontal { flex-direction: row; align-content: center; + margin-top: 1px; } .horizontal > * { @@ -121,10 +122,26 @@ DefaultValueField DropdownField { display: none; } +.st-anim-only .st-anim-only__hide { + display: none; +} + +.st-anim-only .st-pb-prefix__first-retained { + margin-left: 0; +} + +.st-anim-only .st-pb-prefix__first-retained Label.unity-label { + margin-left: 0; +} + #f-remap-to { flex-grow: 1; } +#f-local-only { + display: none; +} + /** Ghostly text for the renameTo text box **/ Label#f-default-param { position: absolute; diff --git a/Editor/Localization/en-US.json b/Editor/Localization/en-US.json index 0838bd4d..6ea71c56 100644 --- a/Editor/Localization/en-US.json +++ b/Editor/Localization/en-US.json @@ -18,6 +18,7 @@ "params.syncmode.Int": "Int", "params.syncmode.Float": "Float", "params.syncmode.Bool": "Bool", + "params.syncmode.PhysBonesPrefix": "PB Prefix", "params.__comment__": "=== Unity 2019 only strings ===", "params.autodetect_header": " Autodetected Parameters ", "params.internal": "Internal", @@ -44,8 +45,8 @@ "merge_parameter.ui.internalParameter.tooltip": "If set, this parameter will be automatically renamed to avoid conflicts with other parameters", "merge_parameter.ui.isPrefix": "Is PhysBone Prefix", "merge_parameter.ui.syncType": "Parameter type", - "merge_parameter.ui.localOnly": "Local Only", - "merge_parameter.ui.localOnly.tooltip": "If set, this parameter will not be synced across the network", + "merge_parameter.ui.synced": "Synced", + "merge_parameter.ui.synced.tooltip": "If set, this parameter will be synced across the network", "merge_parameter.ui.unregistered_foldout": "Unregistered Parameters", "merge_parameter.ui.add_button": "Add", "merge_parameter.ui.details": "Parameter Configuration", diff --git a/Editor/Localization/ja-JP.json b/Editor/Localization/ja-JP.json index f56b9598..38e49dc7 100644 --- a/Editor/Localization/ja-JP.json +++ b/Editor/Localization/ja-JP.json @@ -16,6 +16,7 @@ "params.syncmode.Int": "Int", "params.syncmode.Float": "Float", "params.syncmode.Bool": "Bool", + "params.syncmode.PhysBonesPrefix": "PB Prefix", "params.autodetect_header": " 自動検出されたパラメーター ", "params.internal": "内部値", "params.pb_prefix": "PhysBones接頭辞", @@ -40,8 +41,8 @@ "merge_parameter.ui.internalParameter.tooltip": "有効にすると、名前かぶりを回避するために自動的に名前を変更します", "merge_parameter.ui.isPrefix": "PhysBone 接頭辞", "merge_parameter.ui.syncType": "パラメーター型", - "merge_parameter.ui.localOnly": "ローカルのみ", - "merge_parameter.ui.localOnly.tooltip": "有効にすると、ネットワーク上同期されなくなります", + "merge_parameter.ui.synced": "同期する", + "merge_parameter.ui.synced.tooltip": "有効にすると、ネットワーク上同期されます", "merge_parameter.ui.unregistered_foldout": "未登録パラメーター", "merge_parameter.ui.add_button": "追加", "merge_parameter.ui.details": "パラメーターの詳細設定",