Пример #1
0
        static void SaveLightmaps()
        {
            SceneLightmapList = new List <SceneLightmap>();

            // 5.1 Update path for the generated lightmap assets

            var dsc   = Path.AltDirectorySeparatorChar;
            var scene = SceneManager.GetActiveScene();

            folder_scene = Path.GetDirectoryName(scene.path) + dsc + scene.name + dsc;

            // 5.2 Get all active MeshRenderers with valid lightmap index

            EditorUtils.GetAllPrefabs().ForEach(prefab => {
                var renderers = EditorUtils.GetValidRenderers(prefab.gameObject);

                // 5.3 Store scene lightmaps as assets in target folder

                renderers.ForEach(r => GetOrSaveSceneLightmapToAsset(r.lightmapIndex, prefab.gameObject.name));

                // 5.4 Reference the cloned light maps to the renderer

                EditorUtils.UpdateLightmaps(prefab, renderers, SceneLightmapList);

                // 5.5 Update prefab lights

                EditorUtils.UpdateLights(prefab);

                // 5.6 Save prefab asset in project

                EditorUtils.UpdatePrefab(prefab.gameObject);
            });
        }