- Home /
How can you export a prefab as a package and retain a Lightmap (that was generated by Unity)?
Question: Is it possible to export a prefab as a package that can be imported into another project with the Lightmap information intact?
Details: I'm trying to use a Scene which contains a building model that was Lightmapped using Unity. The geometry was made into a prefab and inside this particular Scene, I can drag the prefab into the Hierarchy and it looks fine.
However, when I create a new scene inside this project -- dragging the same prefab out yields a broken (incorrectly lit) model. The same holds true for exporting a packaged prefab and importing in a new project.
The Lightmapped Scene in Question was setup by someone else who is new to Unity so if it doesn't export/package could that mean it is not setup correctly?
We are using Unity 3.0 - if that is of any relevance.
Thanks in advance for any help/tips/suggestions!
Answer by CuddleBeaver · Nov 29, 2011 at 02:13 PM
As far as I can see the lightmap is tied to the scene, so if you try to export the prefab package with all its dependencies, the lightmaps will not be included. Here is what you have to do:
When you make a lightmap inside Unity, a new folder is created in the same folder as the scene with the same name, containing all the 'near' and 'far' lightmaps.
1) Create a new scene in the existing or new project
2) Import the package containing your prefab with all its dependencies.
3) Drag the prefab into the Hierarchy
4) Copy the folder with the lightmaps from the original scene to the one you want to work with.
5) Inside Unity choose Window -> Lightmapping -> Maps
6) Set the 'array size' to the number of lightmaps - if you have 10 near and 10 far lightmaps, set the array size to 10 (if in doubt look in the same place in the original scene). This creates two columns: The first contains the 'far' lightmaps and the second the 'near' lightmaps.
7) Drag each lightmap from the folder to correct place in the collumns. Again - look in the original scene if in doubt.
This works for me.
Answer by _kiu_ · Jul 25, 2012 at 12:10 PM
Same problem here. Please answer. Was trying to move a project from PC to MAC. LIghtmap UV's are messed up now with some models though settings remains unchanged. What can I do?
Answer by CuddleBeaver · Nov 29, 2011 at 02:02 PM
One more thing. If the lightmapped objects look VERY light, then you have to select each lightmap file, and under Texture Importer -> Texture Type in the Inspector choose 'Lightmap'.
Answer by mattdonlan1 · Dec 07, 2011 at 09:58 AM
I have been using this method with some success. I always seem to have a few objects where the light map is re-applied, but incorrectly. It looks as if the auto-unwrap is flipping some normals between scenes. Has anyone else encountered something similar? The only fix seems to be re-running the light map in the new scene.