public static void ExportAtlasObj(MA_TextureAtlasserProAtlas atlas, string savePath = EXPORTASSETPATH)
        {
            if (atlas == null || atlas.textureQuads == null)
            {
                return;
            }

            foreach (MA_TextureAtlasserProQuad ta in atlas.textureQuads)
            {
                //Export Mesh
                if (ta.meshes != null)
                {
                    for (int m = 0; m < ta.meshes.Count; m++)
                    {
                        if (ta.meshes[m] != null)
                        {
                            //Create new mesh
                            Mesh newMesh = new Mesh();
                            //Duplicate it from the current one
                            newMesh = MA_MeshUtils.MA_DuplicateMesh(ta.meshes[m]);
                            //Remap UV's
                            newMesh = MA_MeshUtils.MA_UVReMap(newMesh, atlas.textureAtlasSize, ta.guiRect);
                            //Save it
                            string modelName = string.IsNullOrEmpty(ta.name) ? "": ta.name + "-";
                            modelName += ta.meshes[m].name;
                            int n = m + 1;
                            modelName += "_" + n.ToString("#000");

                            MA_MeshUtils.MeshToFile(newMesh, modelName, savePath);
                        }
                    }
                }
            }
        }
 public static void ExportAtlasMeshesObj(MA_TextureAtlasserProAtlas atlas, string savePath = EXPORTASSETPATH)
 {
     if (atlas != null && atlas.textureQuads != null)
     {
         foreach (MA_TextureAtlasserProQuad ta in atlas.textureQuads)
         {
             //Export Mesh
             if (ta.meshes != null)
             {
                 for (int m = 0; m < ta.meshes.Count; m++)
                 {
                     if (ta.meshes[m] != null)
                     {
                         //Create new mesh
                         Mesh newMesh = new Mesh();
                         //Duplicate it from the current one
                         newMesh = MA_MeshUtils.MA_DuplicateMesh(ta.meshes[m]);
                         //Remap uvs
                         newMesh = MA_MeshUtils.MA_UVReMap(newMesh, atlas.textureAtlasSize, ta.guiRect);
                         //Save it
                         MA_MeshUtils.MeshToFile(newMesh, "MA_" + ta.name, savePath);
                     }
                 }
             }
         }
     }
 }
Example #3
0
        private static string[] ExportAtlasObj(MA_TextureAtlasserProAtlas atlas, ModelExportSettings modelExportSettings, string savePath = EXPORT_ASSET_PATH)
        {
            if (atlas == null || atlas.textureQuads == null)
            {
                return(null);
            }

            List <string> assetPaths = new List <string>();

            foreach (MA_TextureAtlasserProQuad quad in atlas.textureQuads)
            {
                //Export Mesh
                if (quad.meshes != null)
                {
                    for (int m = 0; m < quad.meshes.Count; m++)
                    {
                        if (quad.meshes[m] != null)
                        {
                            //Create new mesh
                            Mesh newMesh = new Mesh();
                            //Duplicate it from the current one
                            newMesh = MA_MeshUtils.MA_DuplicateMesh(quad.meshes[m]);
                            //Remap UV's
                            newMesh = MA_MeshUtils.MA_UVReMap(newMesh, atlas.textureAtlasSize, quad.guiRect, modelExportSettings.uvChannel, modelExportSettings.uvFlipY, modelExportSettings.uvWrap);
                            //Save it
                            string meshName = string.IsNullOrEmpty(quad.name) ? "" : quad.name + "-";
                            meshName += quad.meshes[m].name;
                            int n = m + 1;
                            meshName += "_" + n.ToString("#000");

                            string asset = MA_MeshUtils.MeshToFile(newMesh, meshName, savePath);
                            assetPaths.Add(asset);
                        }
                    }
                }
            }

            return(assetPaths.ToArray());
        }