public static bool SaveScene()
        {
            bool   saveAsCopy = false;
            string empty      = string.Empty;

            return(EditorApplication.SaveScene(empty, saveAsCopy));
        }
Beispiel #2
0
        void DrawSaveGUI(bool isMine)
        {
            var name   = isMine ? "Mine" : "Theirs";
            var saveAs = GUILayout.Button(string.Format("Save {0} as...", name));

            if (GUILayout.Button(string.Format("Save To {0}", name)) || saveAs)
            {
                var scene = isMine ? mine : theirs;
#if !UNITY_3_4 && !UNITY_3_3 && !UNITY_3_2 && !UNITY_3_1 && !UNITY_3_0_0 && !UNITY_3_0
                var path = AssetDatabase.GetAssetOrScenePath(scene);
#else
                var path = AssetDatabase.GetAssetPath(scene);
#endif

                if (saveAs)
                {
                    var fileName = Path.GetFileNameWithoutExtension(path);
                    path = EditorUtility.SaveFilePanelInProject("Save Mine", fileName, "unity", string.Empty);
                }

                if (!string.IsNullOrEmpty(path))
                {
                    var myContainer    = this.myContainer;
                    var theirContainer = this.theirContainer;
                    DestroyImmediate(isMine ? theirContainer : myContainer);

                    var tmp       = new List <Transform>();
                    var container = isMine ? myContainer : theirContainer;
                    foreach (Transform t in container.transform)
                    {
                        tmp.Add(t);
                    }

                    foreach (var t in tmp)
                    {
                        t.parent = null;
                    }

                    DestroyImmediate(container);

                    (isMine ? mySceneData : theirSceneData).ApplySettings();

#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                    EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), path);
#else
                    EditorApplication.SaveScene(path);
#endif
                    GUIUtility.ExitGUI();
                }
            }
        }
Beispiel #3
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);
         }
     }
 }
        public static bool SaveScene(string path)
        {
            bool saveAsCopy = false;

            return(EditorApplication.SaveScene(path, saveAsCopy));
        }