public static void ExportAllSelectedScene() { Scene currentScene = EditorSceneManager.GetSceneAt(0); var selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets); var paths = (from s in selection let path = AssetDatabase.GetAssetPath(s) where File.Exists(path) && path.EndsWith(".unity") select path).ToArray(); int num = 0; foreach (string item in paths) { EditorUtility.DisplayCancelableProgressBar("导出中", "这会要一些时间,请耐心等待 " + num + "/" + paths.Length, (float)num / (float)paths.Length); if (!EditorSceneManager.GetSceneByPath(item).isLoaded) { currentScene = EditorSceneManager.OpenScene(item); #if OBJECT ScenesFixer.FixFolderPosition(); #endif } WriteXml(); num++; Debug.Log("导出场景为" + item); EditorSceneManager.CloseScene(currentScene, true); } EditorUtility.ClearProgressBar(); }
public void LoadSceneAsync(string sceneName, LoadSceneMode mode, Action onSuccess) { Log.Trace("[ilib-abloader] EditorContainer {0}, LoadSceneAsync {1}. mode{2}", m_Name, sceneName, mode); var paths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(m_Name, sceneName); if (paths.Length == 0) { onSuccess?.Invoke(); return; } LoadSceneParameters parameters = new LoadSceneParameters(mode); EditorSceneManager.LoadSceneAsyncInPlayMode(paths[0], parameters); //Asyncのコールバックが正常に動かないので無理やり実装 var scene = EditorSceneManager.GetSceneByPath(paths[0]); EditorApplication.CallbackFunction onLoad = null; onLoad = () => { if (scene.isLoaded || !scene.IsValid()) { EditorApplication.update -= onLoad; onSuccess?.Invoke(); } }; EditorApplication.update += onLoad; }
public Scene GetMapScene() { string scenePath = GetMapScenePath(); Scene scene = EditorSceneManager.GetSceneByPath(scenePath); return(scene); }
void Init() { string[] guids = AssetDatabase.FindAssets("t:Scene", new string[] { "Assets/Scenes" }); string[] paths = Array.ConvertAll <string, string>(guids, AssetDatabase.GUIDToAssetPath); paths = Array.FindAll(paths, File.Exists); _scenes = new List <string>(paths); list = new ReorderableList(_scenes, typeof(string), true, true, false, false); list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Scenes Availables"); }; list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { string element = _scenes[index]; rect.y += 2; bool enabled = false; EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes; for (int i = 0; i < scenes.Length; ++i) { if (scenes[i].path.Equals(element)) { enabled = scenes[i].enabled; } } if (enabled) { GUI.backgroundColor = Color.green; } EditorGUI.LabelField( new Rect(rect.x, rect.y, rect.width * 0.5f, EditorGUIUtility.singleLineHeight), element.Split('/').Last().Split('.').First() ); GUI.enabled = enabled; if (GUI.Button(new Rect(rect.x + rect.width * 0.5f, rect.y, rect.width * 0.1f - 5, EditorGUIUtility.singleLineHeight), "-")) { RemoveSceneToBuildSettings(element); } GUI.enabled = !enabled; if (GUI.Button(new Rect(rect.x + rect.width * 0.6f, rect.y, rect.width * 0.1f - 5, EditorGUIUtility.singleLineHeight), "+")) { AddSceneToBuildSettings(element); } GUI.enabled = EditorSceneManager.GetActiveScene() != EditorSceneManager.GetSceneByPath(element); if (GUI.Button(new Rect(rect.x + rect.width * 0.7f, rect.y, rect.width * 0.1f - 5, EditorGUIUtility.singleLineHeight), "~")) { MergeSceneToBuildSettings(element); } if (GUI.Button(new Rect(rect.x + rect.width * 0.8f, rect.y, rect.width * 0.2f, EditorGUIUtility.singleLineHeight), "Open")) { EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); EditorSceneManager.OpenScene(element); } GUI.enabled = true; GUI.backgroundColor = Color.white; }; }
public static IEnumerable <GameObject> SceneRoots(string scenePath) { var scene = EditorSceneManager.GetSceneByPath(scenePath); if (Scene_GetRootGameObjects_Method != null && scene.IsValid()) { var roots = (GameObject[])Scene_GetRootGameObjects_Method.Invoke(scene, null); foreach (var root in roots) { yield return(root); } } else { // Fallback; only works in Unity versions without multi-scene support var prop = new HierarchyProperty(HierarchyType.GameObjects); var expanded = new int[0]; while (prop.Next(expanded)) { yield return(prop.pptrValue as GameObject); } } }
private static Scene OpenPackageScene(string exhibitorID) { var scenePath = string.Format("Assets/{0}/{0}.unity", exhibitorID); Debug.Log(scenePath); if (!File.Exists(scenePath)) { throw new FatalValidationErrorException(LocalizedMessage.Get("Vket5TargetFinder.SceneNotFound", scenePath)); } var targetScene = EditorSceneManager.GetSceneByPath(scenePath); Debug.Log(targetScene.name); if (!targetScene.isLoaded) { if (!EditorUtility.DisplayDialog( LocalizedMessage.Get("Vket5TargetFinder.SceneOpenDialog.Title"), LocalizedMessage.Get("Vket5TargetFinder.SceneOpenDialog") + Environment.NewLine + targetScene.path, LocalizedMessage.Get("Vket5TargetFinder.SceneOpenDialog.Continue"), LocalizedMessage.Get("Vket5TargetFinder.SceneOpenDialog.Abort"))) { throw new FatalValidationErrorException(LocalizedMessage.Get("Vket5TargetFinder.ValidationAborted")); } DoSaveIfNecessary(); targetScene = EditorSceneManager.OpenScene(scenePath); EditorSceneManager.SetActiveScene(targetScene); } return(targetScene); }
public static void AddedSceneInHistory(SceneRef scene) { if (!userLoadedScene) { if (sceneHistoryList.Count >= maxLength) { sceneHistoryList.RemoveAt(0); sceneHistoryList.Add(new SceneRef(SceneManager.GetActiveScene().path)); } else { sceneHistoryList.Add(new SceneRef(SceneManager.GetActiveScene().path)); } Debug.Log("Added"); string pathTmp = SceneManager.GetActiveScene().path; EditorSceneManager.SetActiveScene(EditorSceneManager.GetSceneByName(scene.Name)); EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath(pathTmp), true); cursor = sceneHistoryList.Count - 1; } else { /*if (sceneHistoryList.Count >= maxLength) * { * sceneHistoryList.RemoveAt(0); * sceneHistoryList.Add(scene); * } * else * { * sceneHistoryList.Add(scene); * } * cursor = sceneHistoryList.Count - 1;*/ } userLoadedScene = false; }
/// <summary> /// 在编辑器模式下创建一个新的场景,场景放在Assets/Scenes目录下 /// <returns>true:需要创建; false:不需创建</returns> /// </summary> private static bool CreateEmptyScene(string theSceneName) { //string scenePathABS = Application.dataPath; string scenePath = "Assets/Scenes/" + theSceneName + ".unity"; Scene theScene = EditorSceneManager.GetSceneByPath(scenePath); Debug.Log("scenePath|" + scenePath + "|theScene| " + theScene.IsValid()); if (!theScene.IsValid()) { //不存在则创建Scene //提示保存有更改的场景 EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); //创建并保存 Scene newScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single); saveSceneOK = EditorSceneManager.SaveScene(newScene, scenePath); return(true); } else { return(false); } }
private void UpdateScenes() { m_ChangedReferences = 0; for (int i = 0; i < m_Scenes.Count; i++) { List <GameObject> rootObjectsInScene = new List <GameObject>(); string scenePath = AssetDatabase.GetAssetPath(this.m_Scenes[i]); if (EditorPrefs.GetBool("ItemReference.Scene." + scenePath, true)) { Scene scene = EditorSceneManager.GetSceneByPath(scenePath); bool isLoaded = scene.isLoaded; if (!isLoaded) { scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive); } scene.GetRootGameObjects(rootObjectsInScene); UpdateGameObjects(rootObjectsInScene); EditorSceneManager.SaveScene(scene); if (!isLoaded) { EditorSceneManager.CloseScene(scene, false); } } } }
/// <summary> /// Enable/Disable a given scene /// </summary> static public void SetSceneState(SubScene buildScene, bool enable) { if (enable) { if (EditorApplication.isPlaying) { SceneManager.UnloadSceneAsync(EditorSceneManager.GetSceneByPath(buildScene.assetPath)); Debug.Log("Disable " + SceneManager.GetSceneByPath(buildScene.assetPath).name); } else { EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath(buildScene.assetPath), false); Debug.Log("Disable " + EditorSceneManager.GetSceneByPath(buildScene.assetPath).name); } } else { if (EditorApplication.isPlaying) { SceneManager.LoadSceneAsync(buildScene.assetPath, UnityEngine.SceneManagement.LoadSceneMode.Additive); Debug.Log("Enable " + SceneManager.GetSceneByPath(buildScene.assetPath).name); } else { EditorSceneManager.OpenScene(buildScene.assetPath, OpenSceneMode.Additive); Debug.Log("Enable " + EditorSceneManager.GetSceneByPath(buildScene.assetPath).name); } } }
static string[] OnWillSaveAssets( string[] filenames ) { // Do we have any pending actions? If so, execute them now. // This prevents a ctrl-s spam causing us to lose cross-scene references on second save. if ( EditorApplication.delayCall != null ) { var delayCall = EditorApplication.delayCall; EditorApplication.delayCall = null; delayCall(); } // Check if we're saving any scenes List<Scene> savingScenes = new List<Scene>(); foreach( var filename in filenames ) { var scene = EditorSceneManager.GetSceneByPath(filename); if ( scene.IsValid() ) { savingScenes.Add(scene); } } // Weird Unity issue where it doesn't come in here with a filename when saving a new scene (or a non-dirty scene). bool bIsSaveNewScene = (filenames.Length < 1); if ( bIsSaveNewScene ) { savingScenes.Add( EditorSceneManager.GetActiveScene() ); } HandleSavingScenes( savingScenes ); HandleCrossSceneReferences( savingScenes ); return filenames; }
static string[] OnWillSaveAssets( string[] filenames ) { // Check if we're saving any scenes List<Scene> savingScenes = new List<Scene>(); foreach( var filename in filenames ) { var scene = EditorSceneManager.GetSceneByPath(filename); if ( scene.IsValid() ) { savingScenes.Add(scene); } } // Weird Unity issue where it doesn't come in here with a filename when saving a new scene (or a non-dirty scene). bool bIsSaveNewScene = (filenames.Length < 1); if ( bIsSaveNewScene ) { savingScenes.Add( EditorSceneManager.GetActiveScene() ); } HandleSavingScenes( savingScenes ); HandleCrossSceneReferences( savingScenes ); return filenames; }
private void IndexScene(string scenePath, bool checkIfDocumentExists) { bool sceneAdded = false; var scene = EditorSceneManager.GetSceneByPath(scenePath); try { if (scene == null || !scene.isLoaded) { scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive); sceneAdded = scene != null && scene.isLoaded; } if (scene == null || !scene.isLoaded) { return; } var objects = SearchUtils.FetchGameObjects(scene); IndexObjects(objects, "scene", scene.name, checkIfDocumentExists); } finally { if (sceneAdded) { EditorSceneManager.CloseScene(scene, true); } } }
/// <summary> /// Changes the lighting GI workflow of a scene asset /// </summary> /// <param name="workflow"></param> /// <param name="targetSceneAsset"></param> private void ChangeSceneLightingGIWorkflow(SceneAsset targetSceneAsset, Lightmapping.GIWorkflowMode workflow) { var originalSelection = Selection.activeObject; var originalContext = Selection.activeContext; var originalScene = EditorSceneManager.GetActiveScene(); // Find the scene we are on so we can change back to it later string newScenePath = AssetDatabase.GetAssetPath(targetSceneAsset); var newScene = EditorSceneManager.GetSceneByPath(newScenePath); // Get the scene reference of the target scene bool requireSceneLoad = !SceneManagerExtensions.IsSceneLoaded(newScene); // If the scene we are going to change lightmaps on is loaded and dirty, warn the user any changes will be saved if (!requireSceneLoad && newScene.isDirty) { if (!EditorUtility.DisplayDialog("Confirm changing GI Lighting Workflow", $"By changing the GI lighting workflow on \"{newScene.name}\" it will have to be saved, do you want to continue?", "Continue", "Cancel")) { return; } } // If the scene we are trying to change isn't loaded load it if (requireSceneLoad) { EditorSceneManager.OpenScene(newScenePath, OpenSceneMode.Additive); } var loadedScene = EditorSceneManager.GetSceneByPath(newScenePath); // Change active scenes to the target so we can change the settings bool requireSceneChange = originalScene != newScene; if (requireSceneChange) { EditorSceneManager.SetActiveScene(loadedScene); } // Change the lightmap workflow Lightmapping.giWorkflowMode = workflow; EditorSceneManager.SaveScene(loadedScene); // Change back to the original scene if (requireSceneChange) { EditorSceneManager.SetActiveScene(originalScene); } // If we loaded the scene unload it when we're done if (requireSceneLoad) { EditorSceneManager.CloseScene(loadedScene, true); } Selection.SetActiveObjectWithContext(originalSelection, originalContext); }
static public void SaveAllScenes(ScenesPackage package) { SceneField[] scenes = package.GetScenes(includeDependencies: true); for (int i = 0; i < scenes.Length; ++i) { Scene scene = EditorSceneManager.GetSceneByPath(scenes[i].ScenePath); EditorSceneManager.SaveScene(scene); } }
private static bool CleanScenes() { string[] sceneList = AssetDatabase.GetAllAssetPaths() .Where( path => path.EndsWith( ".unity", StringComparison.OrdinalIgnoreCase)) .ToArray(); Scene activeScene = EditorSceneManager.GetActiveScene(); int count = sceneList.Length; int index = 0; for (int i = 0; i < sceneList.Length; i++) { try { if (EditorUtility.DisplayCancelableProgressBar( "Removing components with a missing script", sceneList[i], (float)(index++) / (float)count)) { return(false); } Scene scene = EditorSceneManager.GetSceneByPath(sceneList[i]); if (!scene.isLoaded) { scene = EditorSceneManager.OpenScene( sceneList[i], OpenSceneMode.Additive); } CleanScene(scene); EditorSceneManager.SaveScene(scene); if (scene != activeScene) { EditorSceneManager.CloseScene(scene, true); } } catch (Exception e) { Debug.LogException(e); } } return(true); }
static public Scene LoadMasterScene(bool force = false) { var masterScene = EditorSceneManager.GetSceneByPath("Assets/Scenes/Master.unity"); if (force || !masterScene.IsValid()) { masterScene = EditorSceneManager.OpenScene("Assets/Scenes/Master.unity", OpenSceneMode.Single); } return(masterScene); }
public override void OnInspectorGUI() { EditorGUILayout.LabelField("Manager", titlestyle); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Amount Of Scenes", subtitlestyle); _target.amountScenes = EditorGUILayout.IntField(_target.amountScenes); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Time For Round", subtitlestyle); _target.amountOfTime = EditorGUILayout.FloatField(_target.amountOfTime); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Amount Of Enemies In This Level", subtitlestyle); _target.amountofEnemies = EditorGUILayout.IntField(_target.amountofEnemies); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); scenestoogle = EditorGUILayout.BeginToggleGroup("Levels", scenestoogle); for (int i = 0; i < _target.myscenes.Length; i++) { EditorGUILayout.LabelField("Scene Name: " + _target.myscenes[i].name, subtitlestyle); } EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Get Scenes")) { _target.myscenes = new UnityEngine.SceneManagement.Scene[_target.amountScenes]; Debug.Log(_target.amountScenes); for (int i = 0; i < _target.amountScenes; i++) { _target.myscenes[i] = EditorSceneManager.GetSceneByPath("Assets/Resources/Prefabs/Level" + i + ".unity"); Debug.Log(_target.myscenes[i].name); Repaint(); } } }
public void BuildLightingScenario(string ScenarioName) { //Remove reference to LightingDataAsset so that Unity doesn't delete the previous bake Lightmapping.lightingDataAsset = null; Debug.Log("Baking" + ScenarioName); EditorSceneManager.OpenScene("Assets/Scenes/" + ScenarioName + ".unity", OpenSceneMode.Additive); EditorSceneManager.SetActiveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/" + ScenarioName + ".unity")); StartCoroutine(BuildLightingAsync(ScenarioName)); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { Debug.Log(prop.name); if (scenes == null || scenes.Length == 0) { scenes = EditorBuildSettings.scenes.ToList().Select(s => EditorSceneManager.GetSceneByPath(s.path).name).ToArray(); Debug.Log(string.Join(", ", scenes) + " " + scenes.Length); } SerializedProperty sizeProp = prop.FindPropertyRelative("Array.size"); if (sizeProp.intValue != scenes.Length) { sizeProp.intValue = scenes.Length; } if (prop.isArray) { if (scenes.Length != prop.arraySize) { while (prop.arraySize < scenes.Length) { prop.InsertArrayElementAtIndex(0); } Debug.LogFormat("size:{0} scenes:{1}", prop.arraySize, scenes.Length); for (int i = 0; i < scenes.Length; i++) { int propIndex = i; if (prop.arraySize <= propIndex) { break; } SerializedProperty element = prop.GetArrayElementAtIndex(propIndex); if (element.propertyType == SerializedPropertyType.String) { element.stringValue = scenes[i]; } else { Debug.Log(string.Format("Element {0} - {1}", propIndex, element.propertyType)); } } } } else { EditorGUILayout.HelpBox("Incorrect type", MessageType.Info); } EditorGUI.PropertyField(position, prop, label); }
// Search a scene for references private void SearchScene( string scenePath, List<SearchResultGroup> searchResult, SceneSetup[] initialSceneSetup ) { Scene scene = EditorSceneManager.GetSceneByPath( scenePath ); if( EditorApplication.isPlaying && !scene.isLoaded ) return; bool canContainSceneObjectReference = scene.isLoaded && ( !EditorSceneManager.preventCrossSceneReferences || sceneObjectsToSearchScenesSet.Contains( scenePath ) ); if( !canContainSceneObjectReference ) { bool canContainAssetReference = assetsToSearchSet.Count > 0 && ( EditorApplication.isPlaying || AssetHasAnyReference( scenePath ) ); if( !canContainAssetReference ) return; } if( !EditorApplication.isPlaying ) scene = EditorSceneManager.OpenScene( scenePath, OpenSceneMode.Additive ); currentSearchResultGroup = new SearchResultGroup( scenePath, true ); // Search through all the GameObjects in the scene GameObject[] rootGameObjects = scene.GetRootGameObjects(); for( int i = 0; i < rootGameObjects.Length; i++ ) SearchGameObjectRecursively( rootGameObjects[i] ); // If no references are found in the scene and if the scene is not part of the initial scene setup, close it if( currentSearchResultGroup.NumberOfReferences == 0 ) { if( !EditorApplication.isPlaying ) { bool sceneIsOneOfInitials = false; for( int i = 0; i < initialSceneSetup.Length; i++ ) { if( initialSceneSetup[i].path == scenePath ) { if( !initialSceneSetup[i].isLoaded ) EditorSceneManager.CloseScene( scene, false ); sceneIsOneOfInitials = true; break; } } if( !sceneIsOneOfInitials ) EditorSceneManager.CloseScene( scene, true ); } } else { // Some references are found in this scene, save the results searchResult.Add( currentSearchResultGroup ); } }
static void DoBuildPlayer(string name, BuildTarget target, BuildOptions flags) { var masterScene = EditorSceneManager.GetSceneByPath(kMasterPath); if (!masterScene.IsValid()) { masterScene = EditorSceneManager.OpenScene(kMasterPath); } var msc = Object.FindObjectOfType <MultiSceneController>(); BuildPipeline.BuildPlayer(msc.mainScenePath.scenePaths, string.Format("Builds/{0}", name), target, flags); }
public AmsSceneReference(string scenePath) { #if UNITY_EDITOR var scene = EditorSceneManager.GetSceneByPath(scenePath); editorAssetGUID = AssetDatabase.AssetPathToGUID(scenePath); #else var scene = SceneManager.GetSceneByPath(scenePath); editorAssetGUID = ""; #endif name = scene.name; _path = scene.path; }
public static bool Export(string scenePath, string outputPath) { EditorSceneManager.OpenScene(scenePath); Scene scene = EditorSceneManager.GetSceneByPath(scenePath); if (scene.IsValid()) { return(ExportCurrentScene(outputPath)); } else { return(false); } }
//***Close Otehr Scene*** private void CloseOtherScene() { Scene _currentScene = SceneManager.GetActiveScene(); for (int i = 0; i < flowData.levelNodeDatas.Count; i++) { if (flowData.levelNodeDatas[i].GetScenePath() != _currentScene.path) { //SceneAsset _scene = AssetDatabase.LoadAssetAtPath<SceneAsset>(flowData.levelNodeDatas[i].scenePath); Scene _scene = EditorSceneManager.GetSceneByPath(flowData.levelNodeDatas[i].GetScenePath()); EditorSceneManager.CloseScene(_scene, false); } } }
public void BuildLightingScenario(string ScenarioName) { //Remove reference to LightingDataAsset so that Unity doesn't delete the previous bake Lightmapping.lightingDataAsset = null; if (GLog.IsLogInfoEnabled) { GLog.LogInfo("Baking" + ScenarioName); } EditorSceneManager.OpenScene("Assets/CapstonesRes/Game/Models/Scene/LightingMapData/" + ScenarioName + ".unity", OpenSceneMode.Additive); EditorSceneManager.SetActiveScene(EditorSceneManager.GetSceneByPath("Assets/CapstonesRes/Game/Models/Scene/LightingMapData/" + ScenarioName + ".unity")); StartCoroutine(BuildLightingAsync(ScenarioName)); }
private IEnumerator BuildLightingAsync(string ScenarioName) { var newLightmapMode = new LightmapsMode(); newLightmapMode = LightmapSettings.lightmapsMode; Lightmapping.BakeAsync(); while (Lightmapping.isRunning) { yield return(null); } Lightmapping.lightingDataAsset = null; EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/" + ScenarioName + ".unity")); EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/" + ScenarioName + ".unity"), true); LightmapSettings.lightmapsMode = newLightmapMode; }
private IEnumerator BuildLightingAsync(string ScenarioName) { var newLightmapMode = new LightmapsMode(); newLightmapMode = LightmapSettings.lightmapsMode; Lightmapping.BakeAsync(); while (Lightmapping.isRunning) { yield return(null); } Lightmapping.lightingDataAsset = null; EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/MapData_1212/UPBR_daytime001.unity")); // EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/MapData_1122/UPBR001.unity")); LightmapSettings.lightmapsMode = newLightmapMode; }
public Scene GetScene() { Scene scene = new Scene(); if (IsSceneRefValid()) { #if UNITY_EDITOR scene = EditorSceneManager.GetSceneByPath(_scenePath); #else scene = SceneManager.GetSceneByPath(_scenePath); #endif } return(scene); }
public void Check() { List <string> deleteCandidates = new List <string>(); #if UNITY_EDITOR for (int i = 0; i < EditorSceneManager.sceneCount; i++) { #else for (int i = 0; i < SceneManager.sceneCount; i++) { #endif bool isCandidate = true; foreach (Scene scene in scenes) { #if UNITY_EDITOR if (scene.ScenePath == EditorSceneManager.GetSceneAt(i).path || EditorSceneManager.GetSceneAt(i).path == root) { #else if (scene.ScenePath == SceneManager.GetSceneAt(i).path || SceneManager.GetSceneAt(i).path == root) { #endif isCandidate = false; } } if (isCandidate) { #if UNITY_EDITOR deleteCandidates.Add(EditorSceneManager.GetSceneAt(i).path); #else deleteCandidates.Add(SceneManager.GetSceneAt(i).path); #endif } } foreach (string deleteCandidate in deleteCandidates) { #if UNITY_EDITOR Debug.Log("Delete " + EditorSceneManager.GetSceneByPath(deleteCandidate).name); EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath(deleteCandidate), true); #else Debug.Log("Delete " + SceneManager.GetSceneByPath(deleteCandidate).name); SceneManager.UnloadSceneAsync(SceneManager.GetSceneByPath(deleteCandidate)); #endif } } } }