Skip to content

Commit

Permalink
add SaveSceneDialog if scene is dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
L1247 committed Jan 27, 2023
1 parent 676e946 commit a92882b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;

#endregion
Expand Down Expand Up @@ -665,7 +666,7 @@ private void DrawProjectFinderEntries(string category)
var asset = AssetDatabase.LoadMainAssetAtPath(path);
var entryIsScene = asset is SceneAsset;
var prefabType = PrefabUtility.GetPrefabType(asset);
if (entryIsScene) EditorSceneManager.OpenScene(path , OpenSceneMode.Single);
if (entryIsScene) SaveSceneDialog(path);
else if (prefabType == PrefabType.Prefab) AssetDatabase.OpenAsset(asset);
Selection.activeObject = asset;
}
Expand Down Expand Up @@ -720,6 +721,31 @@ private void DrawProjectFinderEntries(string category)
}
}

private static void SaveSceneDialog(string scenePath)
{
var option = EditorUtility.DisplayDialogComplex(
"Unsaved scene Changes" ,
"Do you want to save the changes you made before load new scene?" ,
"Save" ,
"Cancel" ,
"Don't Save");

switch (option)
{
// Save.
case 0 :
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
EditorSceneManager.OpenScene(scenePath , OpenSceneMode.Single);
break;
// cancel
case 1 : break;
// Don't Save.
case 2 :
EditorSceneManager.OpenScene(scenePath , OpenSceneMode.Single);
break;
}
}

private void DrawSettings()
{
DrawInnerSettings();
Expand Down Expand Up @@ -994,10 +1020,10 @@ private void LoadSettings()

private void OnEnable()
{
titleContent = RetrieveGUIContent("Bookmark" , "CustomSorting");
_defaultGUIColor = GUI.color;
minSize = new Vector2(400 , 400);
_projectFinderTabIndex = EditorPrefs.GetInt(ProjectfindertabindexKey);
titleContent = RetrieveGUIContent("Bookmark" , "CustomSorting");
_defaultGUIColor = GUI.color;
minSize = new Vector2(400 , 400);
_projectFinderTabIndex = EditorPrefs.GetInt(ProjectfindertabindexKey);
lastProjectFinderTabeIndex = _projectFinderTabIndex;
}

Expand Down
2 changes: 1 addition & 1 deletion BookmarkEverything/Assets/BookmarkEverything/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.rstartools.bookmarkeverything",
"displayName": "Bookmark-Everything",
"description": "Bookmark",
"version": "1.0.0",
"version": "1.0.1",
"unity": "2022.2",
"unityRelease": "0f1",
"dependencies": {
Expand Down

0 comments on commit a92882b

Please sign in to comment.