internal static string DoTextField(EditorGUI.RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField) { Event current = Event.current; string result = text; if (text == null) { text = string.Empty; } if (EditorGUI.showMixedValue) { text = string.Empty; } if (EditorGUI.HasKeyboardFocus(id) && Event.current.type != EventType.Layout) { if (editor.IsEditingControl(id)) { editor.position = position; editor.style = style; editor.controlID = id; editor.multiline = multiline; editor.isPasswordField = passwordField; editor.ClampPos(); editor.UpdateScrollOffsetIfNeeded(); } else { if (EditorGUIUtility.editingTextField) { editor.BeginEditing(id, text, position, style, multiline, passwordField); if (GUI.skin.settings.cursorColor.a > 0f) { editor.SelectAll(); } } } } if (editor.controlID == id && GUIUtility.keyboardControl != id) { editor.controlID = 0; } bool flag = false; string text2 = editor.content.text; EventType typeForControl = current.GetTypeForControl(id); switch (typeForControl) { case EventType.MouseDown: if (position.Contains(current.mousePosition) && current.button == 0) { if (editor.IsEditingControl(id)) { if (Event.current.clickCount == 2 && GUI.skin.settings.doubleClickSelectsWord) { editor.MoveCursorToPosition(Event.current.mousePosition); editor.SelectCurrentWord(); editor.MouseDragSelectsWholeWords(true); editor.DblClickSnap(TextEditor.DblClickSnapping.WORDS); EditorGUI.s_DragToPosition = false; } else { if (Event.current.clickCount == 3 && GUI.skin.settings.tripleClickSelectsLine) { editor.MoveCursorToPosition(Event.current.mousePosition); editor.SelectCurrentParagraph(); editor.MouseDragSelectsWholeWords(true); editor.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS); EditorGUI.s_DragToPosition = false; } else { editor.MoveCursorToPosition(Event.current.mousePosition); EditorGUI.s_SelectAllOnMouseUp = false; } } } else { GUIUtility.keyboardControl = id; editor.BeginEditing(id, text, position, style, multiline, passwordField); editor.MoveCursorToPosition(Event.current.mousePosition); if (GUI.skin.settings.cursorColor.a > 0f) { EditorGUI.s_SelectAllOnMouseUp = true; } } GUIUtility.hotControl = id; current.Use(); } goto IL_967; case EventType.MouseUp: if (GUIUtility.hotControl == id) { if (EditorGUI.s_Dragged && EditorGUI.s_DragToPosition) { editor.MoveSelectionToAltCursor(); flag = true; } else { if (EditorGUI.s_PostPoneMove) { editor.MoveCursorToPosition(Event.current.mousePosition); } else { if (EditorGUI.s_SelectAllOnMouseUp) { if (GUI.skin.settings.cursorColor.a > 0f) { editor.SelectAll(); } EditorGUI.s_SelectAllOnMouseUp = false; } } } editor.MouseDragSelectsWholeWords(false); EditorGUI.s_DragToPosition = true; EditorGUI.s_Dragged = false; EditorGUI.s_PostPoneMove = false; if (current.button == 0) { GUIUtility.hotControl = 0; current.Use(); } } goto IL_967; case EventType.MouseMove: case EventType.KeyUp: case EventType.ScrollWheel: IL_121: switch (typeForControl) { case EventType.ValidateCommand: if (GUIUtility.keyboardControl == id) { string commandName = current.commandName; switch (commandName) { case "Cut": case "Copy": if (editor.hasSelection) { current.Use(); } break; case "Paste": if (editor.CanPaste()) { current.Use(); } break; case "SelectAll": current.Use(); break; case "UndoRedoPerformed": editor.content.text = text; current.Use(); break; } } goto IL_967; case EventType.ExecuteCommand: if (GUIUtility.keyboardControl == id) { string commandName = current.commandName; switch (commandName) { case "OnLostFocus": if (EditorGUI.activeEditor != null) { EditorGUI.activeEditor.EndEditing(); } current.Use(); break; case "Cut": editor.BeginEditing(id, text, position, style, multiline, passwordField); editor.Cut(); flag = true; break; case "Copy": editor.Copy(); current.Use(); break; case "Paste": editor.BeginEditing(id, text, position, style, multiline, passwordField); editor.Paste(); flag = true; break; case "SelectAll": editor.SelectAll(); current.Use(); break; } } goto IL_967; case EventType.DragExited: goto IL_967; case EventType.ContextClick: if (position.Contains(current.mousePosition)) { if (!editor.IsEditingControl(id)) { GUIUtility.keyboardControl = id; editor.BeginEditing(id, text, position, style, multiline, passwordField); editor.MoveCursorToPosition(Event.current.mousePosition); } EditorGUI.ShowTextEditorPopupMenu(); Event.current.Use(); } goto IL_967; default: goto IL_967; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == id) { if (!current.shift && editor.hasSelection && EditorGUI.s_DragToPosition) { editor.MoveAltCursorToPosition(Event.current.mousePosition); } else { if (current.shift) { editor.MoveCursorToPosition(Event.current.mousePosition); } else { editor.SelectToPosition(Event.current.mousePosition); } EditorGUI.s_DragToPosition = false; EditorGUI.s_SelectAllOnMouseUp = !editor.hasSelection; } EditorGUI.s_Dragged = true; current.Use(); } goto IL_967; case EventType.KeyDown: if (GUIUtility.keyboardControl == id) { char character = current.character; if (editor.IsEditingControl(id) && editor.HandleKeyEvent(current)) { current.Use(); flag = true; } else { if (current.keyCode == KeyCode.Escape) { if (editor.IsEditingControl(id)) { if (style == EditorStyles.toolbarSearchField || style == EditorStyles.searchField) { EditorGUI.s_OriginalText = string.Empty; } editor.content.text = EditorGUI.s_OriginalText; editor.EndEditing(); flag = true; } } else { if (character == '\n' || character == '\u0003') { if (!editor.IsEditingControl(id)) { editor.BeginEditing(id, text, position, style, multiline, passwordField); editor.SelectAll(); } else { if (multiline && !current.alt && !current.shift && !current.control) { editor.Insert(character); flag = true; goto IL_967; } editor.EndEditing(); } current.Use(); } else { if (character == '\t' || current.keyCode == KeyCode.Tab) { if (multiline && editor.IsEditingControl(id)) { bool flag2 = allowedletters == null || allowedletters.IndexOf(character) != -1; bool flag3 = !current.alt && !current.shift && !current.control && character == '\t'; if (flag3 && flag2) { editor.Insert(character); flag = true; } } } else { if (character != '\u0019' && character != '\u001b') { if (editor.IsEditingControl(id)) { bool flag4 = (allowedletters == null || allowedletters.IndexOf(character) != -1) && character != '\0'; if (flag4) { editor.Insert(character); flag = true; } else { if (Input.compositionString != string.Empty) { editor.ReplaceSelection(string.Empty); flag = true; } current.Use(); } } } } } } } } goto IL_967; case EventType.Repaint: { string text3; if (editor.IsEditingControl(id)) { text3 = ((!passwordField) ? editor.content.text : string.Empty.PadRight(editor.content.text.Length, '*')); } else { if (EditorGUI.showMixedValue) { text3 = EditorGUI.s_MixedValueContent.text; } else { text3 = ((!passwordField) ? text : string.Empty.PadRight(text.Length, '*')); } } if (!string.IsNullOrEmpty(EditorGUI.s_UnitString) && !passwordField) { text3 = text3 + " " + EditorGUI.s_UnitString; } if (GUIUtility.hotControl == 0) { EditorGUIUtility.AddCursorRect(position, MouseCursor.Text); } if (!editor.IsEditingControl(id)) { EditorGUI.BeginHandleMixedValueContentColor(); style.Draw(position, EditorGUIUtility.TempContent(text3), id, false); EditorGUI.EndHandleMixedValueContentColor(); } else { editor.DrawCursor(text3); } goto IL_967; } } goto IL_121; IL_967: if (GUIUtility.keyboardControl == id) { GUIUtility.textFieldInput = true; } changed = false; if (flag) { changed = (text2 != editor.content.text); current.Use(); } if (changed) { GUI.changed = true; return editor.content.text; } EditorGUI.RecycledTextEditor.s_AllowContextCutOrPaste = true; return result; }