refactor: unify logic to determine parameter type and rename confusing variable

This commit is contained in:
nekobako 2024-09-15 18:17:50 +09:00
parent e57d73b41a
commit 6338e42438
2 changed files with 9 additions and 23 deletions

View File

@ -136,10 +136,10 @@ namespace nadena.dev.modular_avatar.core.editor
}
}
var type = mami.ExpressionParametersValueType;
if (valueType == VRCExpressionParameters.ValueType.Bool || type == VRCExpressionParameters.ValueType.Float)
var newValueType = mami.ExpressionParametersValueType;
if (valueType == VRCExpressionParameters.ValueType.Bool || newValueType == VRCExpressionParameters.ValueType.Float)
{
valueType = type;
valueType = newValueType;
}
isSaved |= mami.isSaved;

View File

@ -174,27 +174,13 @@ namespace nadena.dev.modular_avatar.core
}
internal AnimatorControllerParameterType AnimatorControllerParameterType
{
get
=> ExpressionParametersValueType switch
{
// 0, 1
var type = AnimatorControllerParameterType.Bool;
// 2, 3, ..., (255)
if (Control.value > 1)
{
type = AnimatorControllerParameterType.Int;
}
// (-1.0), ..., -0.1, 0.1, ..., 0.9
if (Control.value < 0 || Mathf.Abs(Control.value - Mathf.Round(Control.value)) > 0.01f)
{
type = AnimatorControllerParameterType.Float;
}
return type;
}
}
VRCExpressionParameters.ValueType.Bool => AnimatorControllerParameterType.Bool,
VRCExpressionParameters.ValueType.Int => AnimatorControllerParameterType.Int,
VRCExpressionParameters.ValueType.Float => AnimatorControllerParameterType.Float,
_ => 0,
};
}
}