/// <summary> /// If a lighting scene is being used, this ensures that at least one lighting scene is loaded in editor. /// </summary> private void EditorUpdateLightingScene(bool heirarchyDirty) { if (!profile.UseLightingScene || !profile.EditorManageLoadedScenes) { return; } if (string.IsNullOrEmpty(ActiveLightingScene)) { ActiveLightingScene = profile.DefaultLightingScene.Name; } else { foreach (SceneInfo lightingScene in profile.LightingScenes) { if (lightingScene.Name == ActiveLightingScene) { Scene scene; if (EditorSceneUtils.LoadScene(lightingScene, false, out scene)) { EditorSceneUtils.CopyLightingSettingsToActiveScene(scene); if (profile.EditorEnforceLightingSceneTypes && heirarchyDirty) { EditorEnforceLightingSceneTypes(scene); } } if (profile.EditorEnforceSceneOrder) { // If we're enforcing scene order, make sure this scene comes after the current scene Scene currentFirstScene = EditorSceneManager.GetSceneAt(0); EditorSceneManager.MoveSceneAfter(scene, currentFirstScene); } } else { EditorSceneUtils.UnloadScene(lightingScene, true); } } } }
static void ProcessSceneDecorators( LoadedSceneInfo sceneInfo, Dictionary <string, LoadedSceneInfo> contractMap, Dictionary <string, string> defaultContractsMap) { var decoratedContractName = sceneInfo.DecoratorContext.DecoratedContractName; LoadedSceneInfo decoratedSceneInfo; if (contractMap.TryGetValue(decoratedContractName, out decoratedSceneInfo)) { ValidateDecoratedSceneMatch(sceneInfo, decoratedSceneInfo); return; } decoratedSceneInfo = LoadDefaultSceneForContract( sceneInfo, decoratedContractName, defaultContractsMap); EditorSceneManager.MoveSceneAfter(decoratedSceneInfo.Scene, sceneInfo.Scene); ValidateDecoratedSceneMatch(sceneInfo, decoratedSceneInfo); ProcessScene(decoratedSceneInfo, contractMap, defaultContractsMap); }
private DragAndDropVisualMode DoDragScenes(GameObjectTreeViewItem parentItem, GameObjectTreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos) { List <Scene> list = DragAndDrop.GetGenericData("SceneHeaderList") as List <Scene>; bool flag = list != null; bool flag2 = false; if (!flag && DragAndDrop.objectReferences.Length > 0) { int num = 0; UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences; for (int i = 0; i < objectReferences.Length; i++) { UnityEngine.Object @object = objectReferences[i]; if (@object is SceneAsset) { num++; } } flag2 = (num == DragAndDrop.objectReferences.Length); } if (!flag && !flag2) { return(DragAndDropVisualMode.None); } if (perform) { List <Scene> list2 = null; if (flag2) { List <Scene> list3 = new List <Scene>(); UnityEngine.Object[] objectReferences2 = DragAndDrop.objectReferences; for (int j = 0; j < objectReferences2.Length; j++) { UnityEngine.Object assetObject = objectReferences2[j]; string assetPath = AssetDatabase.GetAssetPath(assetObject); Scene scene = SceneManager.GetSceneByPath(assetPath); if (SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(scene)) { this.m_TreeView.Frame(scene.handle, true, true); } else { bool alt = Event.current.alt; if (alt) { scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.AdditiveWithoutLoading); } else { scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Additive); } if (SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(scene)) { list3.Add(scene); } } } if (targetItem != null) { list2 = list3; } if (list3.Count > 0) { Selection.instanceIDs = (from x in list3 select x.handle).ToArray <int>(); this.m_TreeView.Frame(list3.Last <Scene>().handle, true, false); } } else { list2 = list; } if (list2 != null) { if (targetItem != null) { Scene scene2 = targetItem.scene; if (SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(scene2)) { if (!targetItem.isSceneHeader || dropPos == TreeViewDragging.DropPosition.Upon) { dropPos = TreeViewDragging.DropPosition.Below; } if (dropPos == TreeViewDragging.DropPosition.Above) { for (int k = 0; k < list2.Count; k++) { EditorSceneManager.MoveSceneBefore(list2[k], scene2); } } else if (dropPos == TreeViewDragging.DropPosition.Below) { for (int l = list2.Count - 1; l >= 0; l--) { EditorSceneManager.MoveSceneAfter(list2[l], scene2); } } } } else { Scene sceneAt = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); for (int m = list2.Count - 1; m >= 0; m--) { EditorSceneManager.MoveSceneAfter(list2[m], sceneAt); } } } } return(DragAndDropVisualMode.Move); }
private DragAndDropVisualMode DoDragScenes(GameObjectTreeViewItem parentItem, GameObjectTreeViewItem targetItem, bool perform, DropPosition dropPos) { // We allow dragging SceneAssets on any game object in the Hierarchy to make it easy to drag in a Scene from // the project browser. If dragging on a game object (not a sceneheader) we place the dropped scene // below the game object's scene // Case: 1 List <Scene> scenes = DragAndDrop.GetGenericData(kSceneHeaderDragString) as List <Scene>; bool reorderExistingScenes = (scenes != null); // Case: 2 bool insertNewScenes = false; if (!reorderExistingScenes && DragAndDrop.objectReferences.Length > 0) { int sceneAssetCount = 0; foreach (var dragged in DragAndDrop.objectReferences) { if (dragged is SceneAsset) { sceneAssetCount++; } } insertNewScenes = (sceneAssetCount == DragAndDrop.objectReferences.Length); } // Early out if not case 1 or 2 if (!reorderExistingScenes && !insertNewScenes) { return(DragAndDropVisualMode.None); } if (perform) { List <Scene> scenesToBeMoved = null; if (insertNewScenes) { List <Scene> insertedScenes = new List <Scene>(); foreach (var sceneAsset in DragAndDrop.objectReferences) { string scenePath = AssetDatabase.GetAssetPath(sceneAsset); Scene scene = SceneManager.GetSceneByPath(scenePath); if (SceneHierarchy.IsSceneHeaderInHierarchyWindow(scene)) { m_TreeView.Frame(scene.handle, true, true); } else { bool unloaded = Event.current.alt; if (unloaded) { scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.AdditiveWithoutLoading); } else { scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive); } if (SceneHierarchy.IsSceneHeaderInHierarchyWindow(scene)) { insertedScenes.Add(scene); } } } if (targetItem != null) { scenesToBeMoved = insertedScenes; } // Select added scenes and frame last scene if (insertedScenes.Count > 0) { Selection.instanceIDs = insertedScenes.Select(x => x.handle).ToArray(); m_TreeView.Frame(insertedScenes.Last().handle, true, false); } } else // reorderExistingScenes { scenesToBeMoved = scenes; } if (scenesToBeMoved != null) { if (targetItem != null) { Scene dstScene = targetItem.scene; if (SceneHierarchy.IsSceneHeaderInHierarchyWindow(dstScene)) { if (!targetItem.isSceneHeader || dropPos == DropPosition.Upon) { dropPos = DropPosition.Below; } if (dropPos == DropPosition.Above) { for (int i = 0; i < scenesToBeMoved.Count; i++) { EditorSceneManager.MoveSceneBefore(scenesToBeMoved[i], dstScene); } } else if (dropPos == DropPosition.Below) { for (int i = scenesToBeMoved.Count - 1; i >= 0; i--) { EditorSceneManager.MoveSceneAfter(scenesToBeMoved[i], dstScene); } } } } else { Scene dstScene = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); for (int i = scenesToBeMoved.Count - 1; i >= 0; i--) { EditorSceneManager.MoveSceneAfter(scenesToBeMoved[i], dstScene); } } } } return(DragAndDropVisualMode.Move); }
private DragAndDropVisualMode DoDragScenes(GameObjectTreeViewItem parentItem, GameObjectTreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos) { List <Scene> genericData = DragAndDrop.GetGenericData("SceneHeaderList") as List <Scene>; bool flag1 = genericData != null; bool flag2 = false; if (!flag1 && DragAndDrop.objectReferences.Length > 0) { int num = 0; foreach (UnityEngine.Object objectReference in DragAndDrop.objectReferences) { if (objectReference is SceneAsset) { ++num; } } flag2 = num == DragAndDrop.objectReferences.Length; } if (!flag1 && !flag2) { return(DragAndDropVisualMode.None); } if (perform) { List <Scene> sceneList = (List <Scene>)null; if (flag2) { List <Scene> source = new List <Scene>(); foreach (UnityEngine.Object objectReference in DragAndDrop.objectReferences) { string assetPath = AssetDatabase.GetAssetPath(objectReference); Scene sceneByPath = SceneManager.GetSceneByPath(assetPath); if (SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(sceneByPath)) { this.m_TreeView.Frame(sceneByPath.handle, true, true); } else { Scene scene = !Event.current.alt ? EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Additive) : EditorSceneManager.OpenScene(assetPath, OpenSceneMode.AdditiveWithoutLoading); if (SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(scene)) { source.Add(scene); } } } if (targetItem != null) { sceneList = source; } if (SceneManager.sceneCount - source.Count == 1) { ((TreeViewDataSource)this.m_TreeView.data).SetExpanded(SceneManager.GetSceneAt(0).handle, true); } if (source.Count > 0) { Selection.instanceIDs = source.Select <Scene, int>((Func <Scene, int>)(x => x.handle)).ToArray <int>(); this.m_TreeView.Frame(source.Last <Scene>().handle, true, false); } } else { sceneList = genericData; } if (sceneList != null) { if (targetItem != null) { Scene scene = targetItem.scene; if (SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(scene)) { if (!targetItem.isSceneHeader || dropPos == TreeViewDragging.DropPosition.Upon) { dropPos = TreeViewDragging.DropPosition.Below; } if (dropPos == TreeViewDragging.DropPosition.Above) { for (int index = 0; index < sceneList.Count; ++index) { EditorSceneManager.MoveSceneBefore(sceneList[index], scene); } } else if (dropPos == TreeViewDragging.DropPosition.Below) { for (int index = sceneList.Count - 1; index >= 0; --index) { EditorSceneManager.MoveSceneAfter(sceneList[index], scene); } } } } else { Scene sceneAt = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); for (int index = sceneList.Count - 1; index >= 0; --index) { EditorSceneManager.MoveSceneAfter(sceneList[index], sceneAt); } } } } return(DragAndDropVisualMode.Move); }