Skip to content

Commit a6b8d01

Browse files
committed
Fix relative path creation when manualy creating settings file
1 parent 6a82b59 commit a6b8d01

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Assets/Editor Toolbox/Editor/ToolboxManager.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using UnityEditor;
1+
using System.IO;
2+
using UnityEditor;
23
using UnityEngine;
34

45
namespace Toolbox.Editor
@@ -36,8 +37,6 @@ private static void ManageProjectCore(IToolboxProjectSettings settings)
3637
return;
3738
}
3839

39-
var validateData = !IsInitialized;
40-
4140
//enable/disable the core GUI function
4241
ToolboxEditorProject.IsOverlayAllowed = settings.UseToolboxProject;
4342

@@ -160,15 +159,15 @@ void ReintializeProvider()
160159

161160
//rebuild the settings provider right after initialization
162161
provider.OnDeactivate();
163-
provider.OnActivate("", null);
162+
provider.OnActivate(string.Empty, null);
164163
}
165164

166165
provider.guiHandler = (searchContext) =>
167166
{
168167
if (globalSettingsEditor == null || globalSettingsEditor.serializedObject.targetObject == null)
169168
{
170169
EditorGUILayout.Space();
171-
EditorGUILayout.LabelField("Cannot find " + settingsType + " file located in this Project");
170+
EditorGUILayout.LabelField(string.Format("Cannot find {0} file located in this Project", settingsType));
172171
EditorGUILayout.Space();
173172

174173
if (GUILayout.Button("Create a new settings file"))
@@ -182,9 +181,8 @@ void ReintializeProvider()
182181
return;
183182
}
184183

185-
var relativePath = locationPath
186-
.Substring(locationPath
187-
.IndexOf("Assets/")) + "/" + settingsType + ".asset";
184+
var assetName = string.Format("{0}.asset", settingsType);
185+
var relativePath = Path.Combine(FileUtil.GetProjectRelativePath(locationPath), assetName);
188186

189187
AssetDatabase.CreateAsset(settingsInstance, relativePath);
190188
AssetDatabase.SaveAssets();

0 commit comments

Comments
 (0)