Skip to content

Commit

Permalink
opti: prune garbage sample expression parameters found in VRChat's te…
Browse files Browse the repository at this point in the history
…mplate asset
  • Loading branch information
bdunderscore committed Dec 26, 2023
1 parent aa69856 commit 787b515
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Editor/OptimizationPasses/PruneParametersPass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Linq;
using nadena.dev.ndmf;

namespace nadena.dev.modular_avatar.core.editor
{
internal class PruneParametersPass : Pass<PruneParametersPass>
{
protected override void Execute(ndmf.BuildContext context)
{
var expParams = context.AvatarDescriptor.expressionParameters;
if (expParams != null && context.IsTemporaryAsset(expParams))
{
expParams.parameters = expParams.parameters.Where(p => !string.IsNullOrEmpty(p.name)).ToArray();
}
}
}
}
3 changes: 3 additions & 0 deletions Editor/OptimizationPasses/PruneParametersPass.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Editor/PluginDefinition/PluginDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override void Configure()
seq.Run("Clone animators", AnimationUtil.CloneAllControllers);

seq = InPhase(BuildPhase.Transforming);
seq.Run("Validate configuration",
seq.Run("Validate configuration",
context => ComponentValidation.ValidateAll(context.AvatarRootObject));
seq.WithRequiredExtension(typeof(ModularAvatarContext), _s1 =>
{
Expand Down Expand Up @@ -83,6 +83,7 @@ protected override void Configure()
UnityEngine.Object.DestroyImmediate(component);
}
});
seq.Run(PruneParametersPass.Instance);
});

InPhase(BuildPhase.Optimizing)
Expand Down

0 comments on commit 787b515

Please sign in to comment.