Jump to content

Unity exporter bugs (lightmap, mesh, and textures)


Recommended Posts


I'm using Unity 5.5.0 f3 and I have many bugs with the exporter.

#1 : backed lightmap :
- I have started a new scene with a plan, box, directional light and a camera.
- My light use backed light only
- My meshes use static lightmap
- one standard material for my objects with a texture
- In the exporter window I have checked "export lightmap", synchronous backing enabled, embed shader files.
==> but all my objects are black in the babylonjs preview when I use backed light.


#2 : objects export : 
- I have tested with this model : https://www.assetstore.unity3d.com/en/#!/content/61925
and when I export I have this message : 

FileNotFoundException: Resources/unity_builtin_extra does not exist
System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:107)
BabylonExport.Entities.BabylonScene.AddTexture (System.String texture)
Unity3D2Babylon.SceneBuilder.CopyTexture (System.String texturePath, UnityEngine.Texture2D texture2D, BabylonExport.Entities.BabylonTexture babylonTexture, Boolean isLightmap) (at Assets/Babylon/Source/SceneBuilder.Materials.cs:274)
Unity3D2Babylon.SceneBuilder.DumpTexture (UnityEngine.Texture texture, UnityEngine.Material material, System.String name, Boolean isLightmap) (at Assets/Babylon/Source/SceneBuilder.Materials.cs:1060)
Unity3D2Babylon.SceneBuilder.DumpTextureFromMaterial (UnityEngine.Material material, System.String name) (at Assets/Babylon/Source/SceneBuilder.Materials.cs:1032)
Unity3D2Babylon.SceneBuilder.DumpPBRMaterial (UnityEngine.Material material, Int32 lightmapIndex, Vector4 lightmapScaleOffset, Boolean metallic, Int32 lightmapCoordIndex) (at Assets/Babylon/Source/SceneBuilder.Materials.cs:480)
Unity3D2Babylon.SceneBuilder.DumpMaterial (UnityEngine.Material material, Int32 lightmapIndex, Vector4 lightmapScaleOffset, Int32 lightmapCoordIndex) (at Assets/Babylon/Source/SceneBuilder.Materials.cs:304)
Unity3D2Babylon.SceneBuilder.ConvertUnityMeshToBabylon (UnityEngine.Mesh mesh, UnityEngine.Transform transform, UnityEngine.GameObject gameObject, Single progress, UnityEditor.UnityMetaData& metaData, System.Collections.Generic.List`1& particleSystems, System.Collections.Generic.List`1& lensFlares, System.String& componentTags, BabylonExport.Entities.BabylonMesh collisionMesh, UnityEngine.Collider collider) (at Assets/Babylon/Source/SceneBuilder.Meshes.cs:345)
Unity3D2Babylon.SceneBuilder.ConvertFromUnity () (at Assets/Babylon/Source/SceneBuilder.cs:597)
Unity3D2Babylon.SceneBuilder:ConvertFromUnity() (at Assets/Babylon/Source/SceneBuilder.cs:806)
Unity3D2Babylon.ExporterWindow:Export(Boolean) (at Assets/Babylon/Source/ExporterWindow.cs:736)
Unity3D2Babylon.ExporterWindow:OnGUI() (at Assets/Babylon/Source/ExporterWindow.cs:573)

I have the latest version of today, I have updated the plugin to 2.5 version.

Can you help me to understand please ?


Best regards,


Link to comment
Share on other sites

I have found the problem with the cars models. It was because the car_glass material use "UIMask" texture lol not a real texture file ^^

I meet an other problem in this scene : https://www.assetstore.unity3d.com/en/#!/content/65679
and I have solved it by adding in Tools.cs line 1031 : if(!mesh) return;
I don't know why a mesh is null in this scene...

@Deltakosh I test the new exporter now :-)

Link to comment
Share on other sites

ok I have found the problem, it's because in SceneBuilder.Meshes.cs in ConvertUnityMeshToBabylon you use renderer.sharedMaterial.name as key in multiMatDictionary.

But I see the renderer.sharedMaterial.name is the name of the first material... In this case the model is not realy optimized and have many multi-material starting with the same first material.

To solve that, I concatain all sub materials names in a key :

                        string key = "";
                        for (int i = 0; i < renderer.sharedMaterials.Length; i++)

                        if (!multiMatDictionary.ContainsKey(key))
                            bMultiMat = new BabylonMultiMaterial
                                materials = new string[mesh.subMeshCount],
                                id = Guid.NewGuid().ToString(),
                                name = key//renderer.sharedMaterial.name

                            for (int i = 0; i < renderer.sharedMaterials.Length; i++)
                                var sharedMaterial = renderer.sharedMaterials[i];
                                BabylonMaterial babylonMaterial;

                                babylonMaterial = DumpMaterial(sharedMaterial, renderer.lightmapIndex, renderer.lightmapScaleOffset);

                                bMultiMat.materials[i] = babylonMaterial.id;
                            if (mesh.subMeshCount > 1)
                                multiMatDictionary.Add(bMultiMat.name, bMultiMat);
                            bMultiMat = multiMatDictionary[key];


Capture d’écran 2016-12-20 à 19.27.39.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...