fix: incorrect parameter type detemination for float values

This commit is contained in:
nekobako 2024-09-15 11:43:25 +09:00
parent f8124cae03
commit a93b003129
3 changed files with 48 additions and 14 deletions

View File

@ -34,19 +34,10 @@ namespace nadena.dev.modular_avatar.core.editor
hidden = true;
}
var type = AnimatorControllerParameterType.Bool;
if (type != AnimatorControllerParameterType.Float &&
(_component.Control.value > 1.01 || _component.Control.value < -0.01))
type = AnimatorControllerParameterType.Int;
if (Mathf.Abs(Mathf.Round(_component.Control.value) - _component.Control.value) > 0.01f)
type = AnimatorControllerParameterType.Float;
yield return new ProvidedParameter(
name,
ParameterNamespace.Animator,
_component, PluginDefinition.Instance, type)
_component, PluginDefinition.Instance, _component.AnimatorControllerParameterType)
{
WantSynced = _component.isSynced,
IsHidden = hidden,

View File

@ -136,10 +136,7 @@ namespace nadena.dev.modular_avatar.core.editor
}
}
var type =
Mathf.Abs(mami.Control.value - Mathf.Round(mami.Control.value)) > 0.01f ? VRCExpressionParameters.ValueType.Float
: mami.Control.value < 0 || mami.Control.value > 1 ? VRCExpressionParameters.ValueType.Int
: VRCExpressionParameters.ValueType.Bool;
var type = mami.ExpressionParametersValueType;
if (valueType == VRCExpressionParameters.ValueType.Bool || type == VRCExpressionParameters.ValueType.Float)
{
valueType = type;

View File

@ -149,6 +149,52 @@ namespace nadena.dev.modular_avatar.core
if (control.subParameters.Length > maxSubParams)
control.subParameters = control.subParameters.Take(maxSubParams).ToArray();
}
internal VRCExpressionParameters.ValueType ExpressionParametersValueType
{
get
{
// 0, 1
var type = VRCExpressionParameters.ValueType.Bool;
// 2, 3, ..., (255)
if (Control.value > 1)
{
type = VRCExpressionParameters.ValueType.Int;
}
// (-1.0), ..., -0.1, 0.1, ..., 0.9
if (Control.value < 0 || Mathf.Abs(Control.value - Mathf.Round(Control.value)) > 0.01f)
{
type = VRCExpressionParameters.ValueType.Float;
}
return type;
}
}
internal AnimatorControllerParameterType AnimatorControllerParameterType
{
get
{
// 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;
}
}
}
}