Inheritance: UnityEngine.Object
Ejemplo n.º 1
0
 public static void BakeMultipleScenes(string[] paths)
 {
     if (paths.Length != 0)
     {
         for (int i = 0; i < paths.Length; i++)
         {
             for (int k = i + 1; k < paths.Length; k++)
             {
                 if (paths[i] == paths[k])
                 {
                     throw new Exception("no duplication of scenes is allowed");
                 }
             }
         }
         SetLoadLevelForMultiLevelBake(true);
         string currentScene = EditorApplication.currentScene;
         bool   isSceneDirty = false;
         if (string.IsNullOrEmpty(currentScene))
         {
             isSceneDirty = EditorApplication.isSceneDirty;
             EditorApplication.SaveScene("Temp/MultiLevelBakeTemp.unity", true);
         }
         else
         {
             EditorApplication.SaveScene();
         }
         EditorApplication.OpenScene(paths[0]);
         for (int j = 1; j < paths.Length; j++)
         {
             EditorApplication.OpenSceneAdditive(paths[j]);
         }
         giWorkflowMode = GIWorkflowMode.OnDemand;
         BakeMultipleScenes_Internal(paths);
         foreach (UnityEngine.Object obj2 in AssetDatabase.LoadAllAssetsAtPath(Path.GetDirectoryName(paths[0]) + "/" + Path.GetFileNameWithoutExtension(paths[0]) + "/LightmapSnapshot.asset"))
         {
             LightmapSnapshot snapshot = obj2 as LightmapSnapshot;
             if (snapshot != null)
             {
                 EditorApplication.OpenScene(AssetDatabase.GUIDToAssetPath(snapshot.sceneGUID));
                 giWorkflowMode = GIWorkflowMode.OnDemand;
                 if (lightmapSnapshot != snapshot)
                 {
                     lightmapSnapshot = snapshot;
                     EditorApplication.SaveScene();
                 }
             }
         }
         SetLoadLevelForMultiLevelBake(false);
         if (string.IsNullOrEmpty(currentScene))
         {
             EditorApplication.OpenScene("Temp/MultiLevelBakeTemp.unity");
             EditorApplication.currentScene = string.Empty;
             if (isSceneDirty)
             {
                 EditorApplication.MarkSceneDirty();
             }
         }
         else
         {
             EditorApplication.OpenScene(currentScene);
         }
     }
 }