Unity3d BlendShapes, too many!

Identifying blendShape IDs in FBX objects that have more than you can count

I've been working with Daz3D and Unity3D FBX objects and their blendShapes.  Sometimes, for testing I export EVERYTHING, and it can be 100s of blends.

I've written the following C# code that will allow you to add target meshes and skinnedMeshes to the Inspector and will enumerate each mesh's blends and put them in a CSV file.  From there, you can target the integer based representation that is matched up with the string name of the blend shape.

You could also loop through all blend shape in object, and use name matching to apply blends as well.  A for each blend, if name contains or name equals blink, do xyz. etc... but here is the code that will dump it out to CSV.

This will try and create the directory as well, so be careful to put in a good path.  Also, if an Mesh contains no blends, then  EndOfList - If this is the only entry... will be written to the file.

change the logPath below to your own directory, or just update it in the inspector.

Unity3d C# Code

using System.IO;
using UnityEngine;

public class SharedBodyFunctions : MonoBehaviour {

    public string charName;
    public Mesh[] primaryObjectBlendMeshes;
    public SkinnedMeshRenderer[] skinnedMeshRenderer;
    public string logPath = "S:\\Unity\\Projects7\\Lighting\\Assets\\Logs\\";


 void Start () {
 void Update ()


    void writeBlendShapesToLog()
        string flogPath=logPath + charName;

        { System.IO.Directory.CreateDirectory(flogPath); }
        { print(flogPath + " exists");

        foreach (Mesh primaryObjectBlendMesh in primaryObjectBlendMeshes)
            string logname = primaryObjectBlendMesh.name;
            string uid = primaryObjectBlendMesh.GetHashCode().ToString();
            StreamWriter outputFile = new StreamWriter(flogPath +"\\" + logname + "_" + charName + ".csv", false);
            int f = 0;
                string output = "Unfound";

                try { output = (f + "," + primaryObjectBlendMesh.GetBlendShapeName(f)); }
                catch {output = (f + ", EndOfList - If this is the only entry, then there are no blend shapes for the select SkinnedMesh" ); }
            } while (f < primaryObjectBlendMesh.blendShapeCount);

//as always use at your own risk, even though i have tested it over and over.


Popular posts from this blog

SAPI Interface and Unity3d