Skip to content

Commit

Permalink
Fixed disabled meshes not being included in material dedup scan
Browse files Browse the repository at this point in the history
  • Loading branch information
bigibas123 committed Jun 9, 2024
1 parent 62df5b0 commit fe037fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Editor/MaterialDedup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ protected override void Configure()
.BeforePlugin("com.anatawa12.avatar-optimizer")
.Run("Deduplicate materials", ctx =>
{
var roots = ctx.AvatarRootTransform.GetComponentsInChildren<MaterialDeduplicatorBehavior>();
var roots = ctx.AvatarRootTransform.GetComponentsInChildren<MaterialDeduplicatorBehavior>(true);
foreach (var root in roots)
{
root.AsMaterialRefs(ctx.AvatarDescriptor).AsDedupList().ForEach(d => d.ApplyToDests(root.replaceEvenIfOnlyOne));
root.AsMaterialRefs(ctx.AvatarDescriptor).AsDedupList()
.ForEach(d => d.ApplyToDests(root.replaceEvenIfOnlyOne));
UnityEngine.Object.DestroyImmediate(root);
}
});
Expand Down
4 changes: 2 additions & 2 deletions Runtime/MaterialDeduplicatorBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class MaterialDeduplicatorBehavior : MonoBehaviour, IEditorOnly
private static List<Renderer> GetRenderers(GameObject root)
{
var renderers = new List<Renderer>();
renderers.AddRange(root.GetComponentsInChildren<SkinnedMeshRenderer>());
renderers.AddRange(root.GetComponentsInChildren<MeshRenderer>());
renderers.AddRange(root.GetComponentsInChildren<SkinnedMeshRenderer>(true));
renderers.AddRange(root.GetComponentsInChildren<MeshRenderer>(true));
return renderers;
}
}
Expand Down

0 comments on commit fe037fc

Please sign in to comment.