File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . IO ;
1
3
using UnityEditor ;
2
4
using UnityEngine ;
3
5
@@ -18,21 +20,21 @@ public static Settings Load()
18
20
19
21
private static Settings CreateAsset ( )
20
22
{
21
- var folderPath = "Assets/Editor/Resources" ;
23
+ var folderPath = "Editor/Resources" ;
24
+ var folders = folderPath . Split ( "/" ) ;
25
+ var path = Application . dataPath ;
22
26
23
- var basePath = string . Empty ;
24
- var folders = folderPath . Split ( '/' ) ;
25
-
26
- for ( var i = 1 ; i < folders . Length ; i ++ )
27
+ for ( var i = 0 ; i < folders . Length ; i ++ )
27
28
{
28
- basePath += folders [ i - 1 ] ;
29
- if ( AssetDatabase . GUIDFromAssetPath ( $ "{ basePath } /{ folders [ i ] } ") == null )
30
- AssetDatabase . CreateFolder ( basePath , folders [ i ] ) ;
31
- basePath += "/" ;
29
+ path = Path . Combine ( path , folders [ i ] ) ;
30
+ if ( ! Directory . Exists ( path ) )
31
+ Directory . CreateDirectory ( path ) ;
32
32
}
33
33
34
+ AssetDatabase . Refresh ( ) ;
35
+
34
36
var settings = CreateInstance < Settings > ( ) ;
35
- AssetDatabase . CreateAsset ( settings , $ "{ folderPath } /{ SettingsFilename } .asset") ;
37
+ AssetDatabase . CreateAsset ( settings , $ "Assets/ { folderPath } /{ SettingsFilename } .asset") ;
36
38
EditorUtility . SetDirty ( settings ) ;
37
39
38
40
return settings ;
You can’t perform that action at this time.
0 commit comments