@@ -13,6 +13,7 @@ namespace NuclearBand.Editor
1313 public class ScriptableObjectDatabaseEditorWindow : OdinMenuEditorWindow
1414 {
1515 private bool inSettings = false ;
16+
1617 [ MenuItem ( "Tools/NuclearBand/ScriptableObjectDatabase" ) ]
1718 private static void Open ( )
1819 {
@@ -34,9 +35,9 @@ protected override OdinMenuTree BuildMenuTree()
3435 tree . AddMenuItemAtPath ( new HashSet < OdinMenuItem > ( ) , "" , new OdinMenuItem ( tree , "Settings" , SODatabaseSettings . Instance ) ) ;
3536 return tree ;
3637 }
37-
38+
3839 AddAllAssetsAtPath ( tree , SODatabaseSettings . Path , typeof ( DataNode ) ) ;
39- Texture folderIcon = ( Texture2D ) AssetDatabase . LoadAssetAtPath ( "Packages/com.nuclearband.sodatabase/Editor/folderIcon.png" , typeof ( Texture2D ) ) ;
40+ Texture folderIcon = ( Texture2D ) AssetDatabase . LoadAssetAtPath ( "Packages/com.nuclearband.sodatabase/Editor/folderIcon.png" , typeof ( Texture2D ) ) ;
4041 tree . EnumerateTree ( ) . AddIcons < FolderHolder > ( x => folderIcon ) ;
4142 tree . SortMenuItemsByName ( ) ;
4243 tree . Selection . SelectionChanged += SelectionChanged ;
@@ -45,26 +46,18 @@ protected override OdinMenuTree BuildMenuTree()
4546
4647 private void SelectionChanged ( SelectionChangedType obj )
4748 {
48- try
49+ switch ( obj )
4950 {
50- switch ( obj )
51- {
52- case SelectionChangedType . ItemAdded :
53- ( MenuTree . Selection . SelectedValue as Holder ) . Select ( ) ;
54- break ;
55- case SelectionChangedType . ItemRemoved :
56- break ;
57- case SelectionChangedType . SelectionCleared :
58- break ;
59- default :
60- throw new ArgumentOutOfRangeException ( nameof ( obj ) , obj , null ) ;
61- }
51+ case SelectionChangedType . ItemAdded :
52+ ( MenuTree . Selection . SelectedValue as Holder ) . Select ( ) ;
53+ break ;
54+ case SelectionChangedType . ItemRemoved :
55+ break ;
56+ case SelectionChangedType . SelectionCleared :
57+ break ;
58+ default :
59+ throw new ArgumentOutOfRangeException ( nameof ( obj ) , obj , null ) ;
6260 }
63- catch ( Exception e )
64- {
65-
66- }
67-
6861 }
6962
7063 void AddAllAssetsAtPath (
@@ -73,6 +66,7 @@ void AddAllAssetsAtPath(
7366 Type type )
7467 {
7568 var strings = AssetDatabase . GetAllAssetPaths ( ) . Where ( x => x . StartsWith ( assetFolderPath , StringComparison . InvariantCultureIgnoreCase ) ) ;
69+
7670 var odinMenuItemSet = new HashSet < OdinMenuItem > ( ) ;
7771 foreach ( var str1 in strings )
7872 {
@@ -99,7 +93,7 @@ void AddAllAssetsAtPath(
9993 if ( name == "" )
10094 continue ;
10195 tree . AddMenuItemAtPath ( odinMenuItemSet , path , new OdinMenuItem ( tree , name , new FolderHolder ( path , name ) ) ) ;
102-
96+
10397 continue ;
10498 }
10599
@@ -120,12 +114,14 @@ void AddAllAssetsAtPath(
120114 private static void SplitMenuPath ( string menuPath , out string path , out string name )
121115 {
122116 menuPath = menuPath . Trim ( '/' ) ;
117+
123118 int length = menuPath . LastIndexOf ( '/' ) ;
124119 if ( length == - 1 )
125120 {
126121 path = "" ;
127122 name = menuPath ;
128123 }
124+
129125 else
130126 {
131127 path = menuPath . Substring ( 0 , length ) ;
@@ -143,6 +139,7 @@ protected override void OnBeginDrawEditors()
143139 Close ( ) ;
144140 Open ( ) ;
145141 }
142+
146143 return ;
147144 }
148145
@@ -176,7 +173,7 @@ protected override void OnBeginDrawEditors()
176173 {
177174 var uniqName = AssetDatabase . GenerateUniqueAssetPath ( path + "/" + "New" ) ;
178175 uniqName = uniqName . Substring ( uniqName . LastIndexOf ( '/' ) + 1 ) ;
179-
176+
180177 AssetDatabase . CreateFolder ( path , uniqName ) ;
181178 AssetDatabase . Refresh ( ) ;
182179 }
0 commit comments