public static void Draw(Rect position, SceneReference scene, GUIContent label, AssetLocation location, string newSceneName, Action creator) { var rect = EditorGUI.PrefixLabel(position, label); var refreshRect = RectHelper.TakeTrailingIcon(ref rect); if (GUI.Button(refreshRect, _refreshScenesButton.Content, GUIStyle.none)) { SceneHelper.RefreshLists(); } var list = SceneHelper.GetSceneList(true, location != AssetLocation.None); var index = list.GetIndex(scene.Path); if (index != 0 && scene.IsAssigned) { var loadRect = RectHelper.TakeTrailingIcon(ref rect); var s = scene.Scene; using (ColorScope.ContentColor(Color.black)) { if (s.IsValid() && s.isLoaded) { if (GUI.Button(loadRect, _unloadSceneButton.Content, GUIStyle.none)) { if (EditorSceneManager.SaveModifiedScenesIfUserWantsTo(new Scene[] { s })) { EditorSceneManager.CloseScene(s, true); } } } else { if (GUI.Button(loadRect, _loadSceneButton.Content, GUIStyle.none)) { s = EditorSceneManager.OpenScene(scene.Path, OpenSceneMode.Additive); SceneManager.SetActiveScene(s); } } } } var thumbnail = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset)); var start = scene.Path.LastIndexOf('/') + 1; var popupLabel = index != 0 && scene.IsAssigned ? new GUIContent(scene.Path.Substring(start, scene.Path.Length - start - 6), thumbnail) : new GUIContent("None"); var selection = SelectionPopup.Draw(rect, popupLabel, new SelectionState { Tab = 0, Index = index }, list.Tree); if (selection.Tab == 0 && selection.Index != index) { scene.Path = list.GetPath(selection.Index); } else if (selection.Tab == 1) { var newScene = SceneHelper.CreateScene(location, newSceneName, creator); scene.Path = newScene.path; } if (DragAndDrop.objectReferences.Length > 0 && rect.Contains(Event.current.mousePosition)) { var obj = DragAndDrop.objectReferences[0]; if (obj is SceneAsset asset) { if (Event.current.type == EventType.DragUpdated) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; Event.current.Use(); } if (Event.current.type == EventType.DragPerform) { scene.Path = AssetDatabase.GetAssetPath(asset); DragAndDrop.AcceptDrag(); } } } }