Code Sample: Lightmapping code for prefabs in Unity*

Published: 08/17/2018  

Last Updated: 08/17/2018

File(s): Download
License: Intel Sample Source Code License Agreement
Optimized for...  
OS: Windows® 10
Hardware: N/A
(Programming Language, tool, IDE, Framework)
C#, Unity*
Prerequisites: Familiarity with the Unity’s C# scripting. Unity 5 or beyond installed and configured.


Attach this script as a component to any prefab you might want to lightmap. From the editor window inside Unity you can setup a scene with proper lighting and position your prefabs inside the scene as per your requirements. In the Editor go to Assets-> Bake Prefab Lightmaps which will generate the baked lighting and save it in any prefabs with the script. You can now spawn in different scenes with the baked lighting.

Get Started

Download the code from GitHub* and read Optimization for Unity* Software and Virtual Reality: Run-Time Generated Content for a better understanding of how to prefab you might want to lightmap.


Updated Log

Created July 17, 2018

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at