Пример #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);
            });
        }
Пример #2
0
        public static void Start()
        {
            Debug.ClearDeveloperConsole();

            UpdateLightSettings( );

            // 1. Prepare objects for bake

            // Fetch PrefabVaker components from current active scene
            EditorUtils.GetAllPrefabs( ).ForEach(x => {
                // Set all nested object as static for bake
                EditorUtils.LockForBake(x.gameObject);
            });

            // 2. Display progress dialog and await for bake complete in `BakeCompelte()`
            BakeStart( );

            // 3. Start baking
            Lightmapping.BakeAsync( );
        }
Пример #3
0
        static void OnBakeComplete()
        {
            // 4. Clear progress & events

            BakeFinished( );

            // 5. Fetch lightmaps, apply to prefab and save them in selected folder

            SaveLightmaps();

            if (Window.AutoClean)
            {
                // 6. Delete scene lightmap data

                Lightmapping.ClearLightingDataAsset( );
                Lightmapping.ClearDiskCache( );
                Lightmapping.Clear( );
            }

            // 7. Combine prefab lightmaps with scene lightmaps

            EditorUtils.GetAllPrefabs( ).ForEach(x => Utils.Apply(x));
        }