fix: parameter order is shuffled (#722)

Closes: #713
This commit is contained in:
bd_ 2024-03-03 00:16:28 -08:00 committed by GitHub
parent 8e6d8302ef
commit 962a75f227
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 2 deletions

View File

@ -166,7 +166,7 @@ namespace nadena.dev.modular_avatar.core.editor
.Select(p => ResolveParameter(p, syncParams))
.ToList();
foreach (var kvp in syncParams)
foreach (var kvp in syncParams.OrderBy(kvp => kvp.Value.encounterOrder))
{
var name = kvp.Key;
var param = kvp.Value;

View File

@ -6,7 +6,6 @@ using System.Collections.Immutable;
using System.Linq;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
using nadena.dev.modular_avatar.editor.ErrorReporting;
using nadena.dev.ndmf;
using NUnit.Framework;
using UnityEditor.Animations;
@ -249,6 +248,48 @@ namespace modular_avatar_tests.RenameParametersTests
Assert.IsNotEmpty(errors);
}
[Test]
public void ParameterOrderTest()
{
var av = CreateRoot("avatar");
var rootMenu = ScriptableObject.CreateInstance<VRCExpressionsMenu>();
var paramsAsset = ScriptableObject.CreateInstance<VRCExpressionParameters>();
var desc = av.GetComponent<VRCAvatarDescriptor>();
desc.expressionsMenu = rootMenu;
desc.expressionParameters = paramsAsset;
var c1 = CreateChild(av, "a");
var c2 = CreateChild(av, "b");
var c3 = CreateChild(av, "c");
var c4 = CreateChild(av, "d");
AddParam(c1, "A");
AddParam(c2, "B");
AddParam(c3, "C");
AddParam(c4, "D");
AvatarProcessor.ProcessAvatar(av);
paramsAsset = desc.expressionParameters;
Assert.AreEqual("A", paramsAsset.parameters[0].name);
Assert.AreEqual("B", paramsAsset.parameters[1].name);
Assert.AreEqual("C", paramsAsset.parameters[2].name);
Assert.AreEqual("D", paramsAsset.parameters[3].name);
void AddParam(GameObject child, String name)
{
var param = child.AddComponent<ModularAvatarParameters>();
param.parameters.Add(new ParameterConfig()
{
nameOrPrefix = name,
syncType = ParameterSyncType.Float
});
}
}
}
}