diff --git a/Editor/ParamsUsage/MAParametersIntrospection.cs b/Editor/ParamsUsage/MAParametersIntrospection.cs index cfc3dfe5..54ddf64e 100644 --- a/Editor/ParamsUsage/MAParametersIntrospection.cs +++ b/Editor/ParamsUsage/MAParametersIntrospection.cs @@ -23,7 +23,8 @@ namespace nadena.dev.modular_avatar.core.editor public IEnumerable GetSuppliedParameters(ndmf.BuildContext context = null) { - if (_component.Control == null || _component.GetComponent() == null) yield break; + if (_component.Control == null) yield break; + if (!ParameterAssignerPass.ShouldAssignParametersToMami(_component)) yield break; var hidden = false; var name = _component.Control?.parameter?.name; diff --git a/Editor/ReactiveObjects/ParameterAssignerPass.cs b/Editor/ReactiveObjects/ParameterAssignerPass.cs index d795e169..f8ee170d 100644 --- a/Editor/ReactiveObjects/ParameterAssignerPass.cs +++ b/Editor/ReactiveObjects/ParameterAssignerPass.cs @@ -11,6 +11,23 @@ namespace nadena.dev.modular_avatar.core.editor /// internal class ParameterAssignerPass : Pass { + internal static bool ShouldAssignParametersToMami(ModularAvatarMenuItem item) + { + bool hasRC = false; + foreach (var rc in item.GetComponentsInChildren(true)) + { + // Only track components where this is the closest parent + var parentMami = rc.GetComponentInParent(); + if (parentMami == item) + { + hasRC = true; + break; + } + } + + return hasRC; + } + protected override void Execute(ndmf.BuildContext context) { var paramIndex = 0; @@ -24,7 +41,7 @@ namespace nadena.dev.modular_avatar.core.editor { if (string.IsNullOrWhiteSpace(mami.Control?.parameter?.name)) { - if (mami.GetComponent() == null) continue; + if (!ShouldAssignParametersToMami(mami)) continue; if (mami.Control == null) mami.Control = new VRCExpressionsMenu.Control(); mami.Control.parameter = new VRCExpressionsMenu.Control.Parameter diff --git a/Editor/ReactiveObjects/ShapeChangerPreview.cs b/Editor/ReactiveObjects/ShapeChangerPreview.cs index 0e1a218c..beabb760 100644 --- a/Editor/ReactiveObjects/ShapeChangerPreview.cs +++ b/Editor/ReactiveObjects/ShapeChangerPreview.cs @@ -99,20 +99,6 @@ namespace nadena.dev.modular_avatar.core.editor { _group = group; } - - private bool IsChangerActive(ModularAvatarShapeChanger changer, ComputeContext context) - { - if (changer == null) return false; - - if (context != null) - { - return context.ActiveAndEnabled(changer); - } - else - { - return changer.isActiveAndEnabled; - } - } private HashSet GetToDeleteSet(SkinnedMeshRenderer proxy, ComputeContext context) { @@ -133,9 +119,7 @@ namespace nadena.dev.modular_avatar.core.editor foreach (var changer in _changers) { var shapes = context.Observe(changer, c => c.Shapes.ToImmutableList(), Enumerable.SequenceEqual); - - if (!IsChangerActive(changer, context)) continue; - + foreach (var shape in shapes) if (shape.ChangeType == ShapeChangeType.Delete) { @@ -268,8 +252,6 @@ namespace nadena.dev.modular_avatar.core.editor foreach (var changer in _changers) { - if (!IsChangerActive(changer, null)) continue; - foreach (var shape in changer.Shapes) { var index = mesh.GetBlendShapeIndex(shape.ShapeName);