mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-11 23:19:00 +08:00
fix: menu item with float value incorrectly generates bool parameter
This commit is contained in:
parent
c80d24ea46
commit
988eb9cf3a
@ -115,8 +115,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
var nextValue = 1;
|
||||
|
||||
var canBeBool = true;
|
||||
var canBeInt = true;
|
||||
var valueType = VRCExpressionParameters.ValueType.Bool;
|
||||
var isSaved = false;
|
||||
var isSynced = false;
|
||||
|
||||
@ -137,10 +136,14 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
}
|
||||
}
|
||||
|
||||
if (Mathf.Abs(mami.Control.value - Mathf.Round(mami.Control.value)) > 0.01f)
|
||||
canBeInt = false;
|
||||
else
|
||||
canBeBool &= mami.Control.value is >= 0 and <= 1;
|
||||
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;
|
||||
if (valueType == VRCExpressionParameters.ValueType.Bool || type == VRCExpressionParameters.ValueType.Float)
|
||||
{
|
||||
valueType = type;
|
||||
}
|
||||
|
||||
isSaved |= mami.isSaved;
|
||||
isSynced |= mami.isSynced;
|
||||
@ -148,15 +151,10 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
if (!declaredParams.ContainsKey(paramName))
|
||||
{
|
||||
VRCExpressionParameters.ValueType newType;
|
||||
if (canBeBool) newType = VRCExpressionParameters.ValueType.Bool;
|
||||
else if (canBeInt) newType = VRCExpressionParameters.ValueType.Int;
|
||||
else newType = VRCExpressionParameters.ValueType.Float;
|
||||
|
||||
var newParam = new VRCExpressionParameters.Parameter
|
||||
{
|
||||
name = paramName,
|
||||
valueType = newType,
|
||||
valueType = valueType,
|
||||
saved = isSaved,
|
||||
defaultValue = defaultValue,
|
||||
networkSynced = isSynced
|
||||
|
Loading…
x
Reference in New Issue
Block a user