mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-28 10:15:06 +08:00
fix: MA Parameters bool items + MA Menu Item auto value is broken (#1345)
Closes: #1331
This commit is contained in:
parent
a984cf8673
commit
4405d7aa56
@ -2,8 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using nadena.dev.ndmf;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
using VRC.SDK3.Avatars.ScriptableObjects;
|
||||
|
||||
@ -144,6 +144,12 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
{
|
||||
mami.Control.value = defaultValue.GetValueOrDefault();
|
||||
}
|
||||
else if (p != null && p.valueType != VRCExpressionParameters.ValueType.Int)
|
||||
{
|
||||
// For a float or bool value, we don't really have a lot of good choices, so just set it to
|
||||
// 1
|
||||
mami.Control.value = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (usedValues.Contains(nextValue)) nextValue++;
|
||||
@ -228,7 +234,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
if (simulationInitialStates != null)
|
||||
{
|
||||
var isDefault = mami.isDefault;
|
||||
if (isDefaultOverrides?.TryGetValue(paramName, out var target) == true)
|
||||
ModularAvatarMenuItem target = null;
|
||||
if (isDefaultOverrides?.TryGetValue(paramName, out target) == true)
|
||||
isDefault = ReferenceEquals(mami, target);
|
||||
|
||||
if (isDefault)
|
||||
|
@ -15,6 +15,43 @@ namespace UnitTests.ReactiveComponent.ParameterAssignment
|
||||
{
|
||||
public class AutoValueAssignmentTests : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void AutoValueWithMAParameters()
|
||||
{
|
||||
var root = CreateRoot("root");
|
||||
var child = CreateChild(root, "child");
|
||||
|
||||
var parameters = child.AddComponent<ModularAvatarParameters>();
|
||||
parameters.parameters = new()
|
||||
{
|
||||
new ParameterConfig()
|
||||
{
|
||||
defaultValue = 1.0f,
|
||||
hasExplicitDefaultValue = true,
|
||||
nameOrPrefix = "foo",
|
||||
syncType = ParameterSyncType.Bool
|
||||
}
|
||||
};
|
||||
|
||||
var mami = child.AddComponent<ModularAvatarMenuItem>();
|
||||
mami.Control = new()
|
||||
{
|
||||
parameter = new()
|
||||
{
|
||||
name = "foo"
|
||||
},
|
||||
name = "x"
|
||||
};
|
||||
mami.automaticValue = true;
|
||||
|
||||
child.AddComponent<ModularAvatarMenuInstaller>();
|
||||
|
||||
AvatarProcessor.ProcessAvatar(root);
|
||||
var menu = root.GetComponent<VRCAvatarDescriptor>().expressionsMenu
|
||||
.controls.First(c => c.name == "child");
|
||||
Assert.AreEqual(1, menu.value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ManuallyAssignedParametersAreNotReplaced()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user