Fixes error when merging same parameter with different type in RC menu item (#1313)

This commit is contained in:
Jeremy Lam aka. Vistanz 2024-10-26 11:11:23 +08:00 committed by GitHub
parent 131f54a713
commit 07b648dcc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using nadena.dev.ndmf;
using UnityEngine;
using UnityEditor.Animations;
using VRC.SDK3.Avatars.Components;
using VRC.SDK3.Avatars.ScriptableObjects;
namespace nadena.dev.modular_avatar.core.editor
@ -186,6 +188,22 @@ namespace nadena.dev.modular_avatar.core.editor
expParams.parameters = expParams.parameters.Concat(newParameters.Values).ToArray();
}
if (_mamiByParam.Count > 0)
{
// This make sures the parameters are correctly merged into the FX layer.
var mergeAnimator = context.AvatarRootObject.AddComponent<ModularAvatarMergeAnimator>();
mergeAnimator.layerType = VRCAvatarDescriptor.AnimLayerType.FX;
mergeAnimator.deleteAttachedAnimator = false;
mergeAnimator.animator = new AnimatorController
{
parameters = _mamiByParam.Keys.Select(name => new AnimatorControllerParameter
{
name = name,
type = AnimatorControllerParameterType.Float,
}).ToArray(),
};
}
}
internal static ControlCondition AssignMenuItemParameter(