Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

FBX Exporter not exporting UV4, 5, 6, 7

Discussion in 'Formats & External Tools Previews' started by olix4242, Apr 26, 2022.

  1. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,938
    FBX exporter currently doesn't export UV channels bigger than UV3.
    A fix is quite easy, I just had to change a code in exporter package.

    Code (CSharp):
    1.         /// <summary>
    2.         /// Unity has up to 4 uv sets per mesh. Export all the ones that exist.
    3.         /// </summary>
    4.         /// <param name="fbxMesh">Fbx mesh.</param>
    5.         /// <param name="mesh">Mesh.</param>
    6.         /// <param name="unmergedTriangles">Unmerged triangles.</param>
    7.         private static bool ExportUVs(FbxMesh fbxMesh, MeshInfo mesh, int[] unmergedTriangles)
    8.         {
    9.             Vector2[][] uvs = new Vector2[][] {
    10.                 mesh.UV,
    11.                 mesh.mesh.uv2,
    12.                 mesh.mesh.uv3,
    13.                 mesh.mesh.uv4,
    14.                 mesh.mesh.uv5,
    15.                 mesh.mesh.uv6,
    16.                 mesh.mesh.uv7
    17.             };
    If you look at a comments for a code, you will notice that it says that it only exports first 4 channels because Unity supports only 4 channels. Unity internally supports up to 8 channels, so a code in a package should be changed to reflect this.
    Here comes another problem: even if Unity internally supports more than 4 uv sets (when a mesh is generated procedurally) it's FBX importer can't import other than 4 UV channels. This is an extremely limiting factor in some cases.