@@ -33,23 +33,49 @@ static SettingsProvider NewPreferenceItem()
3333#endif
3434 public static void OnGUI ( )
3535 {
36- Settings . AutoClearLog = EditorGUILayout . ToggleLeft ( "Auto Clear Log" , Settings . AutoClearLog ) ;
36+ Settings . AutoClearLog = ( Settings . ClearLog ) EditorGUILayout . EnumPopup ( "Auto Clear Log" , Settings . AutoClearLog ) ;
37+
38+ EditorGUILayout . BeginHorizontal ( ) ;
3739 Settings . LuaPath = EditorGUILayout . TextField ( "Lua Script File" , Settings . LuaPath ) ;
38- using ( new EditorGUI . DisabledScope ( string . IsNullOrEmpty ( Settings . LuaPath ) ) )
40+ if ( GUILayout . Button ( "Browse" , EditorStyles . miniButton , GUILayout . Width ( 80 ) ) )
41+ BrowseScriptFile ( ) ;
42+ EditorGUILayout . EndHorizontal ( ) ;
43+ if ( ! string . IsNullOrEmpty ( Settings . LuaPath ) && ! File . Exists ( Settings . LuaPath ) )
44+ EditorGUILayout . HelpBox ( "The file not exits" , MessageType . Warning ) ;
45+
46+ using ( new EditorGUI . DisabledScope ( string . IsNullOrEmpty ( Settings . LuaPath ) ) )
3947 {
4048 if ( GUILayout . Button ( "Create defualt lua script" ) )
4149 CreateDefaultScript ( ) ;
4250 }
4351 }
4452
53+ private static void BrowseScriptFile ( )
54+ {
55+ var root = Directory . GetCurrentDirectory ( ) ;
56+ var path = EditorUtility . SaveFilePanel ( "Save File" , root , "" , "lua" ) ;
57+
58+ if ( ! string . IsNullOrEmpty ( path ) )
59+ {
60+ Uri file = new Uri ( path ) ;
61+ Uri folder = new Uri ( root + "/" ) ;
62+ string relativePath =
63+ Uri . UnescapeDataString (
64+ folder . MakeRelativeUri ( file )
65+ . ToString ( )
66+ ) ;
67+ Settings . LuaPath = relativePath ;
68+ }
69+ }
70+
4571 private static void CreateDefaultScript ( )
4672 {
4773 var path = Settings . LuaPath ;
4874 if ( string . IsNullOrEmpty ( path ) ) return ;
4975
5076 if ( File . Exists ( path ) )
5177 {
52- if ( ! EditorUtility . DisplayDialog ( "Save File" ,
78+ if ( ! EditorUtility . DisplayDialog ( "Save File" ,
5379 $ "the file already exists, do you want to overwrite it?\n { path } ",
5480 "Overwrite" , "Cancel" ) )
5581 {
0 commit comments