fix: menu items with no default fail to generate animator controller parameter entries (#1105)

This commit is contained in:
bd_ 2024-09-04 18:58:51 -07:00 committed by GitHub
parent acd6c50543
commit 4fa0621655
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -75,8 +75,10 @@ namespace nadena.dev.modular_avatar.core.editor
{ {
if (condition.IsConstant) continue; if (condition.IsConstant) continue;
if (!initialValues.ContainsKey(condition.Parameter) && condition.InitialValue > -999f) if (!initialValues.TryGetValue(condition.Parameter, out var curVal) || curVal < -999f)
{
initialValues[condition.Parameter] = condition.InitialValue; initialValues[condition.Parameter] = condition.InitialValue;
}
} }
} }

View File

@ -93,8 +93,8 @@ namespace nadena.dev.modular_avatar.core.editor
if (list.Count == 1) if (list.Count == 1)
// If we have only a single entry, it's probably an on-off toggle, so we'll implicitly let 0 // If we have only a single entry, it's probably an on-off toggle, so we'll implicitly let 0
// be the 'unselected' default value // be the 'unselected' default value (if this is not default)
defaultValue = 1; defaultValue = list[0].isDefault ? 1 : 0;
} }
HashSet<int> usedValues = new(); HashSet<int> usedValues = new();
@ -115,9 +115,9 @@ namespace nadena.dev.modular_avatar.core.editor
{ {
if (mami.automaticValue) if (mami.automaticValue)
{ {
if (mami.isDefault) if (list.Count == 1)
{ {
mami.Control.value = defaultValue; mami.Control.value = 1;
} }
else else
{ {