soupday/cc_unity_tools_URP

[Feature] Run build wrinkle map for blend shape index

liudger opened this issue · 2 comments

When combining meshes for better performance the index of the blendshapes changes as there are more blenshapes for some meshed. (eyebrows) It would be nice to have a button to set the index of the wrinkle manager again based on the current blend shapes.
Using Unity Meshbaker https://digitalopus.ca/site/mesh-baker/

image
image

Code is already there. Just need a button!

private void UpdateBlendShapeIndices()
        {
            if (skinnedMeshRenderer && headMaterial)
            {
                Mesh mesh = skinnedMeshRenderer.sharedMesh;

                foreach (WrinkleConfig wc in config)
                {
                    wc.blendShapeIndex = mesh.GetBlendShapeIndex(wc.blendShapeName);
                    wc.enabled = wc.blendShapeIndex >= 0;

                    foreach (WrinkleRuleSet wm in wc.ruleSets)
                    {
                        if (wrinkleRules.TryGetValue(wm.ruleName, out WrinkleRule rule))
                        {
                            wm.enabled = true;
                        }
                        else
                        {
                            wm.enabled = false;
                        }
                    }
                }
            }
        }

created pull request #62