fix: menu item override is not shown in sim for autoprop boolean toggles (#1104)

This commit is contained in:
bd_ 2024-09-04 17:00:08 -07:00 committed by GitHub
parent 89b4c8f921
commit acd6c50543
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -172,10 +172,14 @@ namespace nadena.dev.modular_avatar.core.editor
internal static ControlCondition AssignMenuItemParameter(
ModularAvatarMenuItem mami,
Dictionary<string, float> simulationInitialStates = null,
IDictionary<string, ModularAvatarMenuItem> isDefaultOverrides = null)
IDictionary<string, ModularAvatarMenuItem> isDefaultOverrides = null,
bool? forceSimulation = null
)
{
var isSimulation = (simulationInitialStates != null || forceSimulation == true);
var paramName = mami?.Control?.parameter?.name;
if (mami?.Control != null && simulationInitialStates != null && ShouldAssignParametersToMami(mami))
if (mami?.Control != null && isSimulation && ShouldAssignParametersToMami(mami))
{
paramName = mami.Control?.parameter?.name;
if (string.IsNullOrEmpty(paramName)) paramName = "___AutoProp/" + mami.GetInstanceID();
@ -187,9 +191,10 @@ namespace nadena.dev.modular_avatar.core.editor
if (isDefault)
{
simulationInitialStates[paramName] = mami.Control.value;
} else if (!simulationInitialStates.ContainsKey(paramName))
}
else
{
simulationInitialStates[paramName] = -999;
simulationInitialStates?.TryAdd(paramName, -999);
}
}

View File

@ -268,7 +268,7 @@ namespace nadena.dev.modular_avatar.core.editor.Simulator
return;
}
var prop = ParameterAssignerPass.AssignMenuItemParameter(mami)?.Parameter;
var prop = ParameterAssignerPass.AssignMenuItemParameter(mami, forceSimulation: true)?.Parameter;
if (prop == null)
{
elem.style.display = DisplayStyle.None;