Talk:ObjExporter

From Unify Community Wiki
Jump to: navigation, search

Hi,

Found a small bug when running the code:

It seems like m.subMeshCount in the enclising for loop inside MeshToString() is not always equal to mats.length.

I had to add a extra test around come code to prevent errors:

           //veg: 04-11-2009 added a test for the material being null!
           if (material < mats.Length && mats[material] != null)
           {
               //original code start
               sb.Append("usemtl ").Append(mats[material].name).Append("\n");
               sb.Append("usemap ").Append(mats[material].name).Append("\n");
               //See if this material is already in the materiallist.
               try
               {
                   ObjMaterial objMaterial = new ObjMaterial();
                   objMaterial.name = mats[material].name;
                   if (mats[material].mainTexture)
                       objMaterial.textureName = AssetDatabase.GetAssetPath(mats[material].mainTexture);
                   else
                       objMaterial.textureName = null;
                   materialList.Add(objMaterial.name, objMaterial);
               }
               catch (ArgumentException)
               {
                   //Already in the dictionary
               }
               //original code end
           }

Note that i do not know if the export is still valid. This is more a note of something being wrong in the code and not a permanent fix.

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox