@@ -45,6 +45,7 @@ public static string[] BasicFilters
45
45
46
46
// rename operation:
47
47
bool isRenaming = false ;
48
+ bool FinishRenaming = false ;
48
49
ScriptableObject ObjectToRename = null ;
49
50
string renameText = "" ;
50
51
@@ -524,11 +525,21 @@ private void OptionsButton<T>(T Config) where T : ScriptableObject
524
525
buttonStyle . padding = new RectOffset ( 2 , 2 , 2 , 2 ) ;
525
526
buttonStyle . imagePosition = ImagePosition . ImageOnly ;
526
527
}
527
-
528
- if ( GUILayout . Button ( ConfigOptionsButton , buttonStyle , ConfigOptionsButtonOptions ) )
528
+ if ( isRenaming && ObjectToRename != null && ObjectToRename == Config )
529
529
{
530
- ShowOptionsMenu ( Config ) ;
530
+ if ( GUILayout . Button ( checkIcon , buttonStyle , ConfigOptionsButtonOptions ) )
531
+ {
532
+ FinishRenaming = true ;
533
+ }
531
534
}
535
+ else
536
+ {
537
+ if ( GUILayout . Button ( ConfigOptionsButton , buttonStyle , ConfigOptionsButtonOptions ) )
538
+ {
539
+ ShowOptionsMenu ( Config ) ;
540
+ }
541
+ }
542
+
532
543
}
533
544
534
545
private void ShowOptionsMenu < T > ( T Config ) where T : ScriptableObject
@@ -598,7 +609,7 @@ private void PutPropertiesForObject_H<T>(List<T> Configs) where T : ScriptableOb
598
609
GUIContent propertyContent = new GUIContent ( fileName , fileName ) ;
599
610
600
611
601
- Rect elementRect = GUILayoutUtility . GetRect ( 120 , 120 , 18 , 18 , GUILayout . Width ( 120 ) ) ;
612
+ Rect elementRect = GUILayoutUtility . GetRect ( 120 , 18 , GUILayout . Width ( 120 ) ) ;
602
613
603
614
if ( isRenaming && ObjectToRename != null && ObjectToRename == Config )
604
615
{
@@ -609,28 +620,21 @@ private void PutPropertiesForObject_H<T>(List<T> Configs) where T : ScriptableOb
609
620
610
621
Event e = Event . current ;
611
622
623
+ // textfield + confirm button (for mouse event it must also contain the button area)
624
+ elementRect . width = 145 ;
612
625
if ( isRenaming && e . type == EventType . MouseDown && ! elementRect . Contains ( e . mousePosition ) )
613
626
{
614
627
isRenaming = false ;
615
628
GUI . FocusControl ( null ) ;
616
- e . Use ( ) ; // Olayý tüketiyoruz
617
- }
618
-
619
- if ( GUILayout . Button ( checkButton , buttonStyle , ConfigOptionsButtonOptions ) )
620
- {
621
- AssetDatabase . RenameAsset ( filePath , renameText ) ;
622
- AssetDatabase . SaveAssets ( ) ;
623
- isRenaming = false ;
624
- renameText = "" ;
625
- ObjectToRename = null ;
626
- GUI . FocusControl ( null ) ;
629
+ e . Use ( ) ;
627
630
}
628
631
629
- if ( Event . current . keyCode == KeyCode . Return || Event . current . keyCode == KeyCode . KeypadEnter )
632
+ if ( FinishRenaming || Event . current . keyCode == KeyCode . Return || Event . current . keyCode == KeyCode . KeypadEnter )
630
633
{
631
634
AssetDatabase . RenameAsset ( filePath , renameText ) ;
632
635
AssetDatabase . SaveAssets ( ) ;
633
636
isRenaming = false ;
637
+ FinishRenaming = false ;
634
638
renameText = "" ;
635
639
ObjectToRename = null ;
636
640
GUI . FocusControl ( null ) ;
0 commit comments