Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to export FBX with meshes modified

Discussion in 'Asset Importing & Exporting' started by Jung5, Dec 1, 2021.

  1. Jung5

    Jung5

    Joined:
    Dec 1, 2021
    Posts:
    1
    Can I export FBX with meshes modified?
    I modified meshes of fbx and then export it through my script using "ModelExporter.ExportObject", but it's not working.
    FBX Exporting was okay, but meshes that I modified were not updated.


    GameObject gObj = (GameObject)Selection.activeObject;
    List<Transform> children = new List<Transform>(gObj.transform.GetComponentsInChildren<Transform>());
    bool isUpdated = false;
    foreach( Transform tran in children)
    {

    SkinnedMeshRenderer sm = tran.GetComponent<SkinnedMeshRenderer>();
    MeshFilter mf = tran.GetComponent<MeshFilter>();
    if (!sm.Equals(null))
    {
    if (!sm.sharedMesh.Equals(null))
    {
    sm.sharedMesh = getOutLineNormal(sm.sharedMesh);
    isUpdated = true;
    }
    }
    else if(!mf.Equals(null))
    {
    if (!mf.sharedMesh.Equals(null))
    {
    mf.sharedMesh = getOutLineNormal(mf.sharedMesh);
    isUpdated = true;
    }
    }
    }
    f(isUpdated)
    {
    string filelPath = AssetDatabase.GetAssetPath(gObj);
    filelPath = string.Format("{0}\\{1}_1{2}", Path.GetDirectoryName(filelPath), Path.GetFileNameWithoutExtension(filelPath), Path.GetExtension(filelPath));
    ModelExporter.ExportObject(filelPath, Selection.activeObject);
    Debug.Log("------------------------------------");
    Debug.Log(filelPath);
    Debug.Log("------------------------------------");
    }
     
  2. vkovec

    vkovec

    Unity Developer - FBX Exporter

    Joined:
    Aug 9, 2017
    Posts:
    257
    Hi!

    After running this code, are the meshes in the scene modified? Also, what kind of changes are being made to the meshes?