使用DelayedTextField进行 F2浮动Text修改名字:
if (IsSelected && Event.current.type != EventType.Layout && Event.current.type != EventType.Used && Event.current.keyCode != KeyCode.Backspace && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return)) { GUI.SetNextControlName(FocusHEADNAME); string name = EditorGUI.DelayedTextField(editorRect, HeaderText, EditorStyles.boldLabel); EditorGUI.FocusTextInControl(FocusHEADNAME); if (name != HeaderText) { HeaderText = name; GUI.Label(labelRect, HeaderText, EditorStyles.boldLabel); } isEnterClick = true; isHeadCanEditor = false; EditorGUI.FocusTextInControl(null); Event.current.Use(); // return; } if (IsSelected && isHeadCanEditor) { GUI.SetNextControlName(FocusHEADNAME); string name = EditorGUI.DelayedTextField(editorRect, HeaderText, EditorStyles.boldLabel); EditorGUI.FocusTextInControl(FocusHEADNAME); if (name != HeaderText) { HeaderText = name; // GUI.Label(labelRect, HeaderText, EditorStyles.boldLabel); } }