Skip to content

Commit 42deedb

Browse files
committed
Add information about the default settings in the settings window; minor refactor changes
1 parent 4630c9a commit 42deedb

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Assets/Editor Toolbox/Editor/ToolboxManager.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections;
22
using System.IO;
3+
34
using Unity.EditorCoroutines.Editor;
45
using UnityEditor;
56
using UnityEngine;
@@ -91,15 +92,15 @@ private static void ManageSceneViewCore(IToolboxSceneViewSettings settings)
9192

9293
private static string GetSettingsFileGuid()
9394
{
94-
var guids = AssetDatabase.FindAssets("t:" + settingsType);
95+
var guids = AssetDatabase.FindAssets($"t:{settingsType}");
9596
string targetGuid = null;
9697
//try to find a settings file in a non-package directory
9798
for (var i = guids.Length - 1; i >= 0; i--)
9899
{
99100
var guid = guids[i];
100101
var path = AssetDatabase.GUIDToAssetPath(guid);
101102
targetGuid = guid;
102-
if (path.StartsWith("Assets"))
103+
if (!IsDefaultSettingsPath(path))
103104
{
104105
break;
105106
}
@@ -108,6 +109,11 @@ private static string GetSettingsFileGuid()
108109
return targetGuid;
109110
}
110111

112+
private static bool IsDefaultSettingsPath(string path)
113+
{
114+
return path.StartsWith("Packages");
115+
}
116+
111117
[InitializeOnLoadMethod]
112118
internal static void InitializeToolbox()
113119
{
@@ -223,7 +229,7 @@ void ReintializeProvider()
223229
AssetDatabase.SaveAssets();
224230
AssetDatabase.Refresh();
225231

226-
ToolboxEditorLog.LogInfo("Created a settings file at - " + relativePath);
232+
ToolboxEditorLog.LogInfo($"Created a settings file at - {relativePath}");
227233

228234
ReintializeProvider();
229235
}
@@ -232,7 +238,13 @@ void ReintializeProvider()
232238
}
233239

234240
EditorGUILayout.Space();
235-
EditorGUILayout.LabelField("Settings file location - " + SettingsPath);
241+
EditorGUILayout.LabelField($"Settings file location - {SettingsPath}");
242+
if (IsDefaultSettingsPath(SettingsPath))
243+
{
244+
EditorGUILayout.HelpBox("The currently displayed settings file is the default one, located in the packages directory. " +
245+
"This means all changes can be easily lost. Create a new file for better maintainability.", MessageType.Info);
246+
}
247+
236248
EditorGUILayout.Space();
237249

238250
globalSettingsEditor.OnInspectorGUI();

Assets/Editor Toolbox/Editor/ToolboxPrefs.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ private static string GetKey(string causer, string propertyName)
2020
return string.Format("{0}{3}{1}{3}{2}", "Toolbox", causer, propertyName, ".");
2121
}
2222

23-
2423
public static void DeleteAll()
2524
{
2625
EditorPrefs.DeleteAll();

0 commit comments

Comments
 (0)