void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("INSTANT EVAL"); if (GUILayout.Button("run!")) { /* * var result = UssParser.Parse(script); * UssStyleModifier.Apply( * UssRoot.FindRootInScene().gameObject, * result.styles); */ UssStyleModifier.LoadUss(script); } EditorGUILayout.EndHorizontal(); script = GUI.TextArea(new Rect(0, 30, position.width, 300), script); var editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); if (string.IsNullOrEmpty(editor.SelectedText) == false) { if (prevSelectionText == editor.SelectedText) { return; } var result = UssParser.ParseConditions(editor.SelectedText); Selection.objects = UssStyleModifier.FindObjects( UssRoot.FindRootInScene().gameObject, result); prevSelectionText = editor.SelectedText; } }
private void AddMarker(string marker) { TextEditor textEditor = GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl) as TextEditor; if (textEditor == null) { return; } int searchStartIndex = textEditor.cursorIndex > textEditor.selectIndex ? textEditor.cursorIndex : textEditor.selectIndex; int markerStartIndex = _textToEdit.IndexOf(textEditor.SelectedText, Mathf.Abs(searchStartIndex - textEditor.SelectedText.Length), StringComparison.Ordinal); int markerEndIndex = markerStartIndex + textEditor.SelectedText.Length; string opener = GetOpener(marker); string closer = GetCloser(marker); _undoTexts.Push(_textToEdit); _redoTexts.Clear(); _textToEdit = _textToEdit.Insert(markerStartIndex, opener); _textToEdit = _textToEdit.Insert(markerEndIndex + opener.Length, closer); textEditor.DeleteSelection(); }
public static string HandleCopyPaste(int controlID) { if (controlID == GUIUtility.keyboardControl) { if (Event.current.type == UnityEngine.EventType.KeyUp && (Event.current.modifiers == EventModifiers.Control || Event.current.modifiers == EventModifiers.Command)) { if (Event.current.keyCode == KeyCode.C) { Event.current.Use(); TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.Copy(); } else if (Event.current.keyCode == KeyCode.V) { Event.current.Use(); TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.Paste(); #if UNITY_5_3_OR_NEWER || UNITY_5_3 return(editor.text); //以及更高的unity版本中editor.content.text已经被废弃,需使用editor.text代替 #else return(editor.content.text); #endif } else if (Event.current.keyCode == KeyCode.A) { Event.current.Use(); TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.SelectAll(); } } } return(null); }
IEnumerator FocusOnInputFieldAfterFrame() { yield return(new WaitForEndOfFrame()); ((TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl)).SelectNone(); ((TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl)).MoveTextEnd(); }
void OnGUI() { scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true); { var style = EditorStyles.textField; var wrap = style.wordWrap; style.wordWrap = true; GUI.SetNextControlName("Text"); text = GUILayout.TextArea( text, GUILayout.Width(this.position.width - 25), GUILayout.ExpandHeight(true) ); GUI.FocusControl("Text"); callback(text); style.wordWrap = wrap; } GUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(100))) { callback(originalText); base.Close(); GUIUtility.ExitGUI(); } if (GUILayout.Button("Save", GUILayout.Width(100))) { callback(text); base.Close(); GUIUtility.ExitGUI(); } } EditorGUILayout.EndHorizontal(); var currentEvent = Event.current; if (currentEvent != null && currentEvent.isKey) { if (currentEvent.keyCode == KeyCode.Z && currentEvent.control) { // HACK!!! Otherwise Unity just does an Edit/Undo action currentEvent.Use(); var te = GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl) as TextEditor; if (te != null) { te.Undo(); } } } }
public void MoveTextFieldCursor(SElement elem, ref int?cursor, ref int?selection) { if (!IsFocused(GetFirstComponentID(elem))) { return; } TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); if (elem is STextField) { editor.text = ((STextField)elem).Text; } if (cursor != null) { editor.cursorIndex = cursor.Value; } if (selection != null) { editor.selectIndex = selection.Value; } else { editor.selectIndex = cursor.Value; } cursor = null; selection = null; }
private void CopyToClipboard() { if (Settings.CopyToClipboard && _textsToCopyToClipboardOrdered.Count > 0 && Time.realtimeSinceStartup - _clipboardUpdated > Settings.ClipboardDebounceTime) { try { var builder = new StringBuilder(); foreach (var text in _textsToCopyToClipboardOrdered) { if (text.Length + builder.Length > Settings.MaxClipboardCopyCharacters) { break; } builder.AppendLine(text); } TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.text = builder.ToString(); editor.SelectAll(); editor.Copy(); } catch (Exception e) { Logger.Current.Error(e, "An error while copying text to clipboard."); } finally { _textsToCopyToClipboard.Clear(); _textsToCopyToClipboardOrdered.Clear(); } } }
public static void SelectAll(int len) { TextEditor te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); te.pos = 0; //set cursor position te.selectPos = len; //se }
public void SetCursor(string text, int position) { TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.text = text; editor.MoveTextEnd(); }
public static T DrawEnum <T>(T value, Func <T, bool, RadioButtonType, GUIStyle> styleFunc, Func <T, bool, RadioButtonType, GUIContent> contentFunc) where T : Enum { var controlId = GUIUtility.GetControlID(FocusType.Passive); var state = (RadioButtonsGroupState <T>)GUIUtility.GetStateObject(typeof(RadioButtonsGroupState <T>), controlId); EditorGUILayout.BeginHorizontal(); var enumNames = typeof(T).GetEnumNames(); var enumValues = typeof(T).GetEnumValues(); for (int i = 0; i < enumNames.Length; i++) { var type = RadioButtonType.Middle; if (i == 0) { type = RadioButtonType.Left; } else if (i == enumNames.Length - 1) { type = RadioButtonType.Left; } var currentValue = (T)enumValues.GetValue(i); var selected = currentValue.Equals(value); var style = styleFunc(currentValue, selected, type); var content = contentFunc(currentValue, selected, type); if (GUILayout.Button(content, style)) { state.Selected = currentValue; value = currentValue; } } EditorGUILayout.EndHorizontal(); return(value); }
private static void DoDragAndDrop(ListViewState listView, ListViewElement element, List <ColumnViewElement> columnViewElements, ObjectColumnGetDataFunction getDataForDraggingFunction) { if (GUIUtility.hotControl == listView.ID && Event.current.type == EventType.MouseDown && element.position.Contains(Event.current.mousePosition) && Event.current.button == 0) { var delay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID); delay.mouseDownPosition = Event.current.mousePosition; } if (GUIUtility.hotControl == listView.ID && Event.current.type == EventType.MouseDrag && GUIClip.visibleRect.Contains(Event.current.mousePosition)) { var delay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID); if (delay.CanStartDrag()) { var data = getDataForDraggingFunction == null ? null : getDataForDraggingFunction(columnViewElements[listView.row].value); if (data == null) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.SetGenericData("CustomDragData", data); DragAndDrop.StartDrag(columnViewElements[listView.row].name); Event.current.Use(); } } }
public static String FilePathField(String label, String initialDirectory, String extension, GUIStyle style, params GUILayoutOption[] option) { EditorGUI.BeginChangeCheck(); int controlID = GUIUtility.GetControlID(FocusType.Passive); PathFieldState state = (PathFieldState)GUIUtility.GetStateObject(typeof(PathFieldState), controlID); if (state.currentDirectory == null) { state.currentDirectory = initialDirectory; } GUILayout.BeginHorizontal(option); GUI.tooltip = state.currentFilePath; if (label != null) { GUILayout.Label(label); } GUILayout.Label(new GUIContent(Path.GetFileName(state.currentFilePath), state.currentFilePath), style, GUILayout.ExpandWidth(true)); if (GUILayout.Button("...", EditorStyles.miniButton, GUILayout.Width(20))) { String newPath = EditorUtility.OpenFilePanel("Select a file...", state.currentDirectory, extension); if (String.IsNullOrEmpty(newPath) == false) { state.currentDirectory = Path.GetDirectoryName(newPath); state.currentFilePath = newPath; } } if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(20))) { state.currentFilePath = null; } GUILayout.EndHorizontal(); return(state.currentFilePath); }
void Window(int id) { if (Input.GetKeyDown(KeyCode.Escape)) { display = false; } /* Currently M is the key to send a message to the "Message board" */ else if (Input.GetKeyDown(KeyCode.M)) { Debug.Log("Pressed M."); string message = mBoard.Message + plainText + "\n\n"; mBoard.updateMessageBoard(message); plainText = ""; display = false; } else { plainText = GUI.TextArea(new Rect(20, 20, 3 * Screen.width / 4 - 40, 3 * Screen.height / 4 - 40), plainText); editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); if (Event.current.Equals(Event.KeyboardEvent("tab"))) { Debug.Log("hit tab"); InsertTab(); Event.current.Use(); } } GUI.DragWindow(new Rect(0, 0, 10000, 10000)); //editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); }
public static void Begin(HorizontalPaneState prototype) { int id = GUIUtility.GetControlID(FocusType.Passive); hState = (HorizontalPaneState)GUIUtility.GetStateObject(typeof(HorizontalPaneState), id); hState.ResolveStateToCurrentContext(id, prototype); // *INDENT-OFF* Rect totalArea = EditorGUILayout.BeginHorizontal(); hState.availableWidth = totalArea.width - HorizontalPaneState.SPLITTER_WIDTH; hState.isPaneWidthChanged = false; if(totalArea.width > 0) { if(hState.leftPaneWidth < 0) { if(hState.initialLeftPaneWidth < 0) hState.leftPaneWidth = hState.availableWidth * 0.5f; else hState.leftPaneWidth = hState.initialLeftPaneWidth; hState.isPaneWidthChanged = true; } if(hState.lastAvailableWidth < 0) hState.lastAvailableWidth = hState.availableWidth; if(hState.lastAvailableWidth != hState.availableWidth) { hState.leftPaneWidth = hState.availableWidth * (hState.leftPaneWidth / hState.lastAvailableWidth); hState.isPaneWidthChanged = true; } hState.lastAvailableWidth = hState.availableWidth; } GUILayout.BeginHorizontal(GUILayout.Width(hState.leftPaneWidth)); // *INDENT-ON* }
// Update general keys void UpdateGeneralKeys() { if (Event.current.type != EventType.KeyUp) { return; } switch (Event.current.keyCode) { case KeyCode.Escape: //popupMenu = null; if (popupWindow != null) { popupWindow.Close(); } if (!introEnabled && (accountNameFocused || accountPasswordFocused)) { GUIHelper.ClearAllFocus(); } break; // TODO: This doesn't work with KeyDown...but why? case KeyCode.A: if (Event.current.modifiers == EventModifiers.Control && GUIUtility.keyboardControl != 0) { TextEditor t = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); t.SelectAll(); } break; } }
public static void Begin(VerticalPaneState prototype) { int id = GUIUtility.GetControlID(FocusType.Passive); vState = (VerticalPaneState)GUIUtility.GetStateObject(typeof(VerticalPaneState), id); vState.ResolveStateToCurrentContext(id, prototype); // *INDENT-OFF* Rect totalArea = EditorGUILayout.BeginVertical(); vState.availableHeight = totalArea.height - VerticalPaneState.SPLITTER_HEIGHT; vState.isPaneHeightChanged = false; if (totalArea.height > 0) { if (vState.topPaneHeight < 0) { if (vState.initialTopPaneHeight < 0) vState.topPaneHeight = vState.availableHeight * 0.5f; else vState.topPaneHeight = vState.initialTopPaneHeight; vState.isPaneHeightChanged = true; } if (vState.lastAvailableHeight < 0) vState.lastAvailableHeight = vState.availableHeight; if (vState.lastAvailableHeight != vState.availableHeight) { vState.topPaneHeight = vState.availableHeight * (vState.topPaneHeight / vState.lastAvailableHeight); vState.isPaneHeightChanged = true; } vState.lastAvailableHeight = vState.availableHeight; } GUILayout.BeginVertical(GUILayout.Height(vState.topPaneHeight)); // *INDENT-ON* }
public static void WordDiff(string content, bool showFileNames) { int id = GUIUtility.GetControlID(FocusType.Passive); WordDiffState state = (WordDiffState)GUIUtility.GetStateObject(typeof(WordDiffState), id); state.content = content; state.showFileNames = showFileNames; Line[] lines = state.lines; Color oldColor = GUI.contentColor; GUILayout.BeginVertical(); foreach (Line line in lines) { GUILayout.BeginHorizontal(); for (int i = 0; i < line.segments.Length; i++) { GUILayout.Label(line.segments[i], line.styles[i], GUILayout.Width(line.widths[i]), NoExpandWidth); } GUILayout.EndHorizontal(); GUI.contentColor = oldColor; } GUILayout.EndVertical(); }
internal static bool HandleDelayedDrag(Rect position, int id, UnityEngine.Object objectToDrag) { Event current = Event.current; EventType typeForControl = current.GetTypeForControl(id); if (typeForControl != EventType.MouseDown) { if ((typeForControl == EventType.MouseDrag) && (GUIUtility.hotControl == id)) { DragAndDropDelay stateObject = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), id); if (stateObject.CanStartDrag()) { GUIUtility.hotControl = 0; PrepareStartDrag(); UnityEngine.Object[] objArray = new UnityEngine.Object[] { objectToDrag }; objectReferences = objArray; StartDrag(ObjectNames.GetDragAndDropTitle(objectToDrag)); return(true); } } } else if ((position.Contains(current.mousePosition) && (current.clickCount == 1)) && ((current.button == 0) && ((Application.platform != RuntimePlatform.OSXEditor) || !current.control))) { GUIUtility.hotControl = id; DragAndDropDelay delay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), id); delay.mouseDownPosition = current.mousePosition; return(true); } return(false); }
/// <summary> /// Creates key field /// </summary> /// <param name="key">field key</param> /// <param name="text">field label</param> /// <param name="xBoxes">x boxes</param> /// <returns>value</returns> public static string KeyField(string key, string text, float xBoxes) { Background(xBoxes); GUI.SetNextControlName("Key TextField"); key = TextField(key, xBoxes - 3); if (key == "") { Label(text, xBoxes - 3); } Move(xBoxes - 3, 0); GUI.FocusControl("Key TextField"); if (Button("R")) { key = ""; } Move(1, 0); if (Button("Insert", 2)) { TextEditor textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.GetControlID(FocusType.Keyboard)); textEditor.SelectAll(); textEditor.Paste(); textEditor.SelectAll(); key = textEditor.SelectedText; textEditor.SelectNone(); } Move(2 - xBoxes, 0); return(key); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (_styles == null) { _styles = new Styles(); _textEdtior.style = _styles.textField; } base.OnGUI(position, property, label); ContentState contentState = (ContentState)GUIUtility.GetStateObject(typeof(ContentState), controlID); State state = new State(); state.controlID = controlID; state.position = position; state.property = property; state.current = Event.current; if (contentState.text == null) { contentState.text = ""; } ProcessEvent(ref state, label, contentState); DrawSearchArea(ref state, label, contentState); }
void SetCursorPos(int pos) { TextEditor te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); te.pos = pos; te.selectPos = te.pos; }
/// <summary> /// Thanks to https://forum.unity.com/threads/how-to-copy-and-paste-in-a-custom-editor-textfield.261087/ /// Add copy-paste functionality to any text field /// Returns changed text or NULL. /// Usage: text = HandleCopyPaste (controlID) ?? text; /// </summary> public static string HandleCopyPaste(int controlID) { if (Event.current.type == EventType.KeyUp && (Event.current.modifiers == EventModifiers.Control || Event.current.modifiers == EventModifiers.Command)) { if (Event.current.keyCode == KeyCode.C) { Event.current.Use(); TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.Copy(); } else if (Event.current.keyCode == KeyCode.V) { Event.current.Use(); TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); /* Debug.Log(editor.text); * * editor.Paste(); * Debug.Log(editor.text);*/ return(editor.text); } else if (Event.current.keyCode == KeyCode.A) { Event.current.Use(); TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.SelectAll(); return(editor.text); } } return(null); }
private static void DoDragAndDrop(ListViewState listView, ListViewElement element, List <ColumnViewElement> columnViewElements, ObjectColumnGetDataFunction getDataForDraggingFunction) { if (((GUIUtility.hotControl == listView.ID) && (Event.current.type == EventType.MouseDown)) && (element.position.Contains(Event.current.mousePosition) && (Event.current.button == 0))) { DragAndDropDelay stateObject = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID); stateObject.mouseDownPosition = Event.current.mousePosition; } if (((GUIUtility.hotControl == listView.ID) && (Event.current.type == EventType.MouseDrag)) && GUIClip.visibleRect.Contains(Event.current.mousePosition)) { DragAndDropDelay delay2 = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID); if (delay2.CanStartDrag()) { object data = getDataForDraggingFunction?.Invoke(columnViewElements[listView.row].value); if (data != null) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[0]; DragAndDrop.paths = null; DragAndDrop.SetGenericData("CustomDragData", data); DragAndDrop.StartDrag(columnViewElements[listView.row].name); Event.current.Use(); } } } }
void DrawEditor() { editorArea.Begin(); editorScrollPosition = GUILayout.BeginScrollView(editorScrollPosition); GUI.SetNextControlName(textAreaControlName); string text = GUILayout.TextArea(currentFile != null ? currentFile.source : "No file loaded..", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); if (GUIUtility.keyboardControl == editor.controlID && Event.current.Equals(Event.KeyboardEvent("tab"))) { if (text.Length > editor.pos) { text = text.Insert(editor.pos, "\t"); editor.pos++; editor.selectPos = editor.pos; } Event.current.Use(); } if (currentFile != null) { currentFile.source = text; } GUILayout.EndScrollView(); editorArea.End(); }
// We want to use down or up to navigate the search results. However, those keys also change the // cursor index in the text field. We "revert" that behavior like this. private void OnDownOrUpPressed() { TextEditor txt = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); m_CurrentTextCursorIndex = txt.cursorIndex; m_DownOrUpPressedThisFrame = true; }
void codeWindow() { currentCode = obj.script; GUILayout.Label(" Code Window:"); _codeScrollPos = GUILayout.BeginScrollView(_codeScrollPos, new GUILayoutOption[] { GUILayout.Height(Screen.height / 2), GUILayout.ExpandHeight(false) }); obj.script = GUILayout.TextArea(currentCode, new GUILayoutOption[] { GUILayout.ExpandHeight(true) }); GUILayout.EndScrollView(); //Debug.Log(_codeScrollPos); //_codeScrollPos.y = 1; TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); //Debug.Log(editor.cursorIndex); if (Event.current.type == EventType.KeyUp && !_nameFlag && !_scriptFlag) { if (Event.current.keyCode == KeyCode.UpArrow) { _codeScrollPos.y -= 16; } if (Event.current.keyCode == KeyCode.DownArrow || Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) { _codeScrollPos.y += 16; } } //else //{ // if (Event.current.keyCode == KeyCode.UpArrow) { _codeScrollPos.y -= 12; Debug.Log("up arrow"); } // if (Event.current.keyCode == KeyCode.DownArrow) { _codeScrollPos.y += 12; Debug.Log("down arrow"); } //} }
internal static bool HandleDelayedDrag(Rect position, int id, Object objectToDrag) { Event current = Event.current; switch (current.GetTypeForControl(id)) { case EventType.MouseDown: if (position.Contains(current.mousePosition) && current.clickCount == 1 && current.button == 0 && (Application.platform != RuntimePlatform.OSXEditor || !current.control)) { GUIUtility.hotControl = id; ((DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), id)).mouseDownPosition = current.mousePosition; return(true); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == id && ((DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), id)).CanStartDrag()) { GUIUtility.hotControl = 0; DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new Object[1] { objectToDrag }; DragAndDrop.StartDrag(ObjectNames.GetDragAndDropTitle(objectToDrag)); return(true); } break; } return(false); }
// Small hack. public void ProcessKeys(int controlId) { if (controlId == GUIUtility.keyboardControl) { if (Event.current.type == EventType.KeyUp && (Event.current.modifiers == EventModifiers.Control || Event.current.modifiers == EventModifiers.Command)) { if (Event.current.keyCode == KeyCode.C) { var editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); editor.Copy(); Event.current.Use(); } else if (Event.current.keyCode == KeyCode.V) { var textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); textEditor.Paste(); _filterValue = textEditor.text; Event.current.Use(); } else if (Event.current.keyCode == KeyCode.A) { var textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); textEditor.SelectAll(); Event.current.Use(); } } } }
// Token: 0x06004EA1 RID: 20129 RVA: 0x001456D4 File Offset: 0x001438D4 private static bool GetTextEditor(out TextEditor te) { global::UIUnityEvents.submit = false; if (!global::UIUnityEvents.focusSetInOnGUI && global::UIUnityEvents.requiresBinding && global::UIUnityEvents.lastInput && global::UIUnityEvents.lastInputCamera) { GUI.FocusControl("ngui-unityevents"); } global::UIUnityEvents.Bind(); te = (GUIUtility.GetStateObject(typeof(TextEditor), global::UIUnityEvents.controlID) as TextEditor); if (global::UIUnityEvents.lastInput) { GUIContent guicontent; if ((guicontent = global::UIUnityEvents.textInputContent) == null) { guicontent = (global::UIUnityEvents.textInputContent = new GUIContent()); } guicontent.text = global::UIUnityEvents.lastInput.inputText; te.content.text = global::UIUnityEvents.textInputContent.text; te.SaveBackup(); te.position = global::UIUnityEvents.idRect; te.style = global::UIUnityEvents.textStyle; te.multiline = global::UIUnityEvents.lastInput.inputMultiline; te.controlID = global::UIUnityEvents.controlID; te.ClampPos(); return(true); } te = null; return(false); }
private static void DoDragAndDrop(ListViewState listView, ListViewElement element, List <ColumnViewElement> columnViewElements, ColumnView.ObjectColumnGetDataFunction getDataForDraggingFunction) { if (GUIUtility.hotControl == listView.ID && Event.current.type == EventType.MouseDown && element.position.Contains(Event.current.mousePosition) && Event.current.button == 0) { DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID); dragAndDropDelay.mouseDownPosition = Event.current.mousePosition; } if (GUIUtility.hotControl == listView.ID && Event.current.type == EventType.MouseDrag && GUIClip.visibleRect.Contains(Event.current.mousePosition)) { DragAndDropDelay dragAndDropDelay2 = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), listView.ID); if (dragAndDropDelay2.CanStartDrag()) { object obj = (getDataForDraggingFunction != null) ? getDataForDraggingFunction(columnViewElements[listView.row].value) : null; if (obj == null) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[0]; DragAndDrop.paths = null; DragAndDrop.SetGenericData("CustomDragData", obj); DragAndDrop.StartDrag(columnViewElements[listView.row].name); Event.current.Use(); } } }