@@ -470,7 +470,52 @@ private void PutPropertiesForObject_V<T>(List<T> Configs) where T : ScriptableOb
470
470
// Display the file name and a delete button for the asset
471
471
EditorGUILayout . BeginHorizontal ( ) ;
472
472
GUIContent propertyContent = new GUIContent ( fileName , fileName ) ;
473
- EditorGUILayout . LabelField ( propertyContent , EditorStyles . miniBoldLabel , GUILayout . MinWidth ( PropertyMinWidth ) ) ;
473
+
474
+ Rect elementRect = GUILayoutUtility . GetRect ( 120 , 18 ) ;
475
+
476
+ if ( isRenaming && ObjectToRename != null && ObjectToRename == Config )
477
+ {
478
+ GUI . SetNextControlName ( "RenameField" ) ;
479
+
480
+ // Display a text field for renaming the asset.if renameText is empty, show the file name until the user types something
481
+ renameText = EditorGUI . TextField ( elementRect , renameText == "" ? fileName : renameText ) ;
482
+
483
+ Event e = Event . current ;
484
+
485
+ // textfield + confirm button (for mouse event it must also contain the button area)
486
+ elementRect . width += 25 ;
487
+ if ( isRenaming && e . type == EventType . MouseDown && ! elementRect . Contains ( e . mousePosition ) )
488
+ {
489
+ isRenaming = false ;
490
+ GUI . FocusControl ( null ) ;
491
+ e . Use ( ) ;
492
+ }
493
+
494
+ if ( FinishRenaming || Event . current . keyCode == KeyCode . Return || Event . current . keyCode == KeyCode . KeypadEnter )
495
+ {
496
+ AssetDatabase . RenameAsset ( filePath , renameText ) ;
497
+ AssetDatabase . SaveAssets ( ) ;
498
+ isRenaming = false ;
499
+ FinishRenaming = false ;
500
+ renameText = "" ;
501
+ ObjectToRename = null ;
502
+ GUI . FocusControl ( null ) ;
503
+ }
504
+ else if ( Event . current . keyCode == KeyCode . Escape )
505
+ {
506
+ renameText = "" ;
507
+ isRenaming = false ;
508
+ ObjectToRename = null ;
509
+ GUI . FocusControl ( null ) ;
510
+ }
511
+
512
+ EditorGUI . FocusTextInControl ( "RenameField" ) ;
513
+ }
514
+ else
515
+ {
516
+ EditorGUI . LabelField ( elementRect , propertyContent , EditorStyles . miniBoldLabel ) ;
517
+ }
518
+
474
519
OptionsButton ( Config ) ;
475
520
EditorGUILayout . EndHorizontal ( ) ;
476
521
0 commit comments