private void BeginInspectorPopup(SerializedProperty property, TypeFilter typeFilter) { treeView.TypeFilter = typeFilter; outputProperty = property; searchField.SetFocus(); treeView.DragEnabled = false; }
public void FocusSearch() { if (UserPrefs.ShowSearchField) { searchField.SetFocus(); } }
private void HandleSearchField() { var newFilter = m_SearchField.OnToolbarGUI(m_Filter, null); SetFilter(newFilter); m_SearchField.SetFocus(); }
private void AssetListGUI() { GUILayout.BeginHorizontal(); GUILayout.Space(10); searchMode = (SearchMode)EditorGUILayout.EnumPopup(searchMode, GUILayout.Width(80)); Rect rect = GUILayoutUtility.GetRect(position.width - 130, 25); rect.height = 20; rect.y += 3; searchText = searchField.OnGUI(rect, searchText); if (searchField.HasFocus() && Event.current.rawType == EventType.KeyUp && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter)) { projecListTreeView.Filtter(searchText, searchMode); searchField.SetFocus(); } if (GUILayout.Button(createAssetIcon, GUILayout.Width(20), GUILayout.Height(17))) { string path = EditorUtility.SaveFilePanelInProject("创建", "New TimelineLite", "asset", ""); if (!string.IsNullOrEmpty(path)) { AssetDatabase.CreateAsset(ScriptableObject.CreateInstance(TimelineLiteAssetType), path); AssetDatabase.Refresh(); } } GUILayout.Space(10); GUILayout.EndHorizontal(); rect.x = 10; rect.y += 20; rect.width = position.width - 20; rect.height = position.height - rect.y - 5; projecListTreeView.OnGUI(rect); }
void DoSearchField(Rect rect, bool asToolbar) { if (searchField == null) { searchField = new SearchField(); searchField.SetFocus(); searchField.downOrUpArrowKeyPressed += OnDownOrUpArrowKeyPressed; } var result = asToolbar ? searchField.OnToolbarGUI(rect, searchString) : searchField.OnGUI(rect, searchString); if (result != searchString && onInputChanged != null) { onInputChanged(result); selectedIndex = 0; showResults = true; } searchString = result; if (HasSearchbarFocused()) { RepaintFocusedWindow(); } }
public void SetFocus() { if (searchField != null) { searchField.SetFocus(); } }
private void OnEnable() { filterComponentsField = new SearchField(); filterComponentsField.SetFocus(); addComponentsField = new SearchField(); observer = target as EntityObserver; observer.DisplayDropDown = false; }
private void OnEnable() { scenes = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes); searchField = new SearchField(); searchField.SetFocus(); Research(); }
public override void OnOpen() { TreeViewState treeViewState = new TreeViewState(); treeView = new PopupMenuTreeView(treeViewState, values); treeView.onValueSelected += OnValueSelected; searchField = new SearchField(); searchField.downOrUpArrowKeyPressed += treeView.SetFocusAndEnsureSelectedItem; searchField.SetFocus(); }
public override void OnOpen() { enumNames = serializedProperty.enumNames; TreeViewState treeViewState = new TreeViewState(); treeView = new EnumPopupTreeView(treeViewState, enumNames); treeView.onEnumSelected += OnEnumSelected; searchField = new SearchField(); searchField.downOrUpArrowKeyPressed += treeView.SetFocusAndEnsureSelectedItem; searchField.SetFocus(); }
public InputControlPicker(SerializedProperty pathProperty, TreeViewState treeViewState = null) { if (pathProperty == null) { throw new ArgumentNullException("pathProperty"); } m_PathProperty = pathProperty; m_PathTreeState = treeViewState ?? new TreeViewState(); m_SearchField = new SearchField(); m_SearchField.SetFocus(); m_SearchField.downOrUpArrowKeyPressed += OnDownOrUpArrowKeyPressed; }
private void HandleSearchField() { m_SearchField.SetFocus(); var newSearchContent = m_SearchField.OnToolbarGUI(m_SearchContent, null); if (newSearchContent == m_SearchContent) { return; } m_SearchContent = newSearchContent; OnSearchInput?.Invoke(m_SearchContent); FilterDevicesBySearchContent(); CalculateScrollPosition(); }
protected void OnEnable() { Current = this; if (!string.IsNullOrEmpty(filePath)) { Load(filePath, out languages, out dataTable); } searchField = new SearchField(); searchField.SetFocus(); UpdateSearchType(); treeView = new LanguageTreeView(new TreeViewState(), LocalizationMultiColumnHeader.GetHeader(), searchText, searchFlags); treeView.Filtter(searchText, searchFlags); treeView.onLanguageCountChanged += UpdateSearchType; }
internal void DrawSearchField(bool isSearchFieldDisabled, string searchString, Action <string> searchChanged) { if (!isSearchFieldDisabled && !m_FocusSet) { m_FocusSet = true; m_SearchField.SetFocus(); } using (new EditorGUI.DisabledScope(isSearchFieldDisabled)) { var newSearch = DrawSearchFieldControl(searchString); if (newSearch != searchString) { searchChanged(newSearch); } } }
private void Init() { viewState = CreateInstance <ViewState>(); if (File.Exists(assetPath)) { FromJsonOverwrite(File.ReadAllText(assetPath), viewState); } tree = new PrefabSelectionTreeView(viewState.treeViewState); tree.onSelectEntry += OnSelectEntry; AssetPreview.SetPreviewTextureCacheSize(tree.RowsCount); searchField = new SearchField(); searchField.downOrUpArrowKeyPressed += tree.SetFocusAndEnsureSelectedItem; searchField.SetFocus(); }
public AddBehaviourPopup(TransitionProfile _profile, List <StateBehaviour> _list) { profile = _profile; list = _list; searchField = new SearchField(); searchField.SetFocus(); var scripts = (MonoScript[])Resources.FindObjectsOfTypeAll(typeof(MonoScript)); foreach (var script in scripts) { var type = script.GetClass(); if (type != null && typeof(StateBehaviour).IsAssignableFrom(type) && !type.IsAbstract) { behaviourTypes.Add(script.name); } } }
/// <summary> /// Draws the search component. /// </summary> protected virtual void DrawSearch() { GUILayout.Space(5f); using (new EditorGUILayout.HorizontalScope()) { GUILayout.Space(5f); Vector2 labelSize = searchLabelPrefixStyle.CalcSize(searchLabelPrefixContent); GUILayoutOption widthLayoutOption = GUILayout.Width(labelSize.x); using (new EditorGUILayout.VerticalScope(widthLayoutOption)) { GUILayout.Space(3f); EditorGUILayout.LabelField(searchLabelPrefixContent, searchLabelPrefixStyle, widthLayoutOption); Rect labelRect = GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(labelRect, MouseCursor.Link); Event currentEvent = Event.current; if (currentEvent.type == EventType.MouseUp && labelRect.Contains(currentEvent.mousePosition)) { Application.OpenURL("https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions"); currentEvent.Use(); } } searchField.SetFocus(); string newSearchText = searchField.OnGUI(EditorGUILayout.GetControlRect(false), searchText); if (searchText != newSearchText) { FindElements(newSearchText); } GUILayout.Space(3f); } }
public void Focus() { searchField.SetFocus(); }
public void FocusSearchField() { searchField = searchField ?? new SearchField(); searchField.SetFocus(); }
public UTinyAnimatedTree(string name) { s_ComponentSearchField = new SearchField(); s_ComponentSearchField.SetFocus(); Add(new GroupElement(0, name, "")); }
void UpdateEditor() { EditorGUILayout.Space(); if (GUILayout.Button(new GUIContent("Destroy"), GUILayout.Height(20))) { observer.OnEntityDestroy(entity); } EditorGUILayout.Space(); #if UNITY_EDITOR && NANOECS_DEBUG var componentObservers = new List <ComponentObserver>(entity.ComponentObservers); var rawTypes = observer.ComponentsLookup.Keys; var usedTypes = rawTypes .Where(type => HasTypes(type, componentObservers)) .ToArray(); var unusedTypes = rawTypes .Where(type => !HasTypes(type, componentObservers)) .ToArray(); filterComponentString = filterComponentsField.OnGUI(EditorGUILayout.GetControlRect(), filterComponentString); var filter = filterComponentString == null ? null : filterComponentString.Replace(' ', ',').Split(new char[] { ',', ' ', '.', ';' }).Where(x => x != null).Where(x => x != ""); var filteredTypes = (filterComponentString == null || filterComponentString == "") ? usedTypes : usedTypes .Where(type => { foreach (var f in filter) { var lowerType = type.ToLower(); var lowerF = f.ToLower(); if (lowerType.Contains(lowerF)) { return(true); } } return(false); }).ToArray(); foreach (var componentObserver in componentObservers) { var component = componentObserver.Component; var type = component.GetType(); var name = type.Name; if (!filteredTypes.Contains(name)) { continue; } GUILayout.Space(5); name = name.Replace("Component", ""); GUILayout.BeginHorizontal(NanoEditorHelper.backStyle(component.GetHashCode())); var fields = type.GetFields( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).Where(f => f.FieldType != typeof(Action <ushort>)).ToList(); bool hasToRemove = false; if (fields.Count > 0) { GUILayout.Space(15); componentObserver.IsFoldout = EditorGUILayout.Foldout(componentObserver.IsFoldout, name, true); } else { EditorGUILayout.LabelField(name); } if (GUILayout.Button("✕", GUILayout.Width(19), GUILayout.Height(19))) { hasToRemove = true; } GUILayout.EndHorizontal(); if (hasToRemove) { entity.RemoveComponentOfIndex(observer.ComponentsLookup[component.GetType().ToString()]); } if (!componentObserver.IsFoldout) { continue; } foreach (var field in fields) { GUILayout.BeginHorizontal(NanoEditorHelper.backStyle(component.GetHashCode())); DrawField(component, fields, field); GUILayout.EndHorizontal(); } } GUILayout.Space(25); if (!observer.DisplayDropDown) { if (GUILayout.Button(new GUIContent("Add Component"), GUILayout.Height(20))) { addComponentsField.SetFocus(); observer.DisplayDropDown = true; } } if (observer.DisplayDropDown) { var r = EditorGUILayout.GetControlRect(); r.height = 20; observer.CurrentComponentName = EditorExtend.TextFieldAutoComplete(addComponentsField, r, observer.CurrentComponentName, unusedTypes, (string value) => value.Replace("Component", ""), maxShownCount: 10, levenshteinDistance: 0.5f); } if (observer.ComponentsLookup.ContainsKey(observer.CurrentComponentName)) { entity.Add <ComponentEcs>(observer.ComponentsLookup[observer.CurrentComponentName]); observer.CurrentComponentName = string.Empty; } Event e = Event.current; if (e.type == EventType.Ignore || (e.type == EventType.MouseDown)) { observer.DisplayDropDown = false; } GUILayout.Space(50); if (target != null) { EditorUtility.SetDirty(target); } #endif }
protected virtual void OnGUI() { Event currentEvent = Event.current; if (type == null || currentEvent.type == EventType.KeyDown && currentEvent.keyCode == KeyCode.Escape && string.IsNullOrEmpty(searchText)) { Close(); return; } Type[] matchingComponentTypes = componentTypes .Where(type1 => Regex.IsMatch(type1.Name, $".*{searchText}.*", RegexOptions.IgnoreCase)) .ToArray(); if (currentEvent.type == EventType.KeyDown) { if (currentEvent.keyCode == KeyCode.DownArrow) { selectionIndex++; Repaint(); return; } if (currentEvent.keyCode == KeyCode.UpArrow) { selectionIndex--; Repaint(); return; } } selectionIndex = Math.Min(matchingComponentTypes.Length - 1, Math.Max(0, selectionIndex)); using (new EditorGUILayout.VerticalScope("grey_border")) { const float searchRectPadding = 8f; Rect searchRect = GUILayoutUtility.GetRect(36f, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); searchRect.x += searchRectPadding; searchRect.y = 7f; searchRect.width -= searchRectPadding * 2f; searchRect.height = 30f; searchField.SetFocus(); searchText = searchField.OnGUI(searchRect, searchText); EditorGUILayout.Separator(); using (EditorGUILayout.ScrollViewScope scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosition, EditorStyles.helpBox)) { scrollPosition = scrollViewScope.scrollPosition; if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0 || currentEvent.type == EventType.KeyDown && (currentEvent.keyCode == KeyCode.Return || currentEvent.keyCode == KeyCode.KeypadEnter)) { selectAction(matchingComponentTypes[selectionIndex]); Close(); return; } for (int index = 0; index < matchingComponentTypes.Length; index++) { Color previousBackgroundColor = GUI.backgroundColor; Texture2D previousNormalBackground = labelStyle.normal.background; if (selectionIndex == index) { GUI.backgroundColor = GUI.skin.settings.selectionColor; labelStyle.normal.background = Texture2D.whiteTexture; EditorGUILayout.BeginHorizontal(); } Type matchingComponentType = matchingComponentTypes[index]; EditorGUILayout.LabelField( new GUIContent( ObjectNames.NicifyVariableName(matchingComponentType.Name), AssetPreview.GetMiniTypeThumbnail(matchingComponentType)), labelStyle); if (selectionIndex == index) { EditorGUILayout.EndHorizontal(); labelStyle.normal.background = previousNormalBackground; GUI.backgroundColor = previousBackgroundColor; } if (currentEvent.type == EventType.MouseMove && GUILayoutUtility.GetLastRect().Contains(currentEvent.mousePosition)) { selectionIndex = index; Repaint(); return; } } } } }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); GUILayout.Label(filePath); GUILayout.FlexibleSpace(); if (GUILayout.Button("Save", (GUIStyle)"toolbarbutton", GUILayout.Width(100))) { if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath)) { Save(filePath); } else { string path = EditorUtility.SaveFilePanelInProject("Save", "language", "json", "", Application.dataPath); if (!string.IsNullOrEmpty(path)) { Save(path); } } } int i = EditorGUILayout.Popup(-1, Enum.GetNames(typeof(DataFormat)), (GUIStyle)"ToolbarDropDownToggle", GUILayout.Width(20)); if (i != -1) { string path = ""; switch (i) { case 0: path = EditorUtility.SaveFilePanelInProject("Save", "language", "json", "", Application.dataPath); break; case 1: path = EditorUtility.SaveFilePanelInProject("Save", "language", "csv", "", Application.dataPath); break; } if (!string.IsNullOrEmpty(path)) { Save(path); } } GUILayout.Space(10); if (GUILayout.Button("Load", (GUIStyle)"toolbarbutton", GUILayout.Width(100))) { string path = EditorUtility.OpenFilePanel("Select", Application.dataPath, "json,csv"); if (!string.IsNullOrEmpty(path)) { Load(path, out languages, out dataTable); treeView.TotalReload(); } } EditorGUILayout.EndHorizontal(); Rect rect = new Rect(lineSpace, 30, 50, lineHeight); if (GUI.Button(rect, new GUIContent("Reload", "Load from file")) && !string.IsNullOrEmpty(filePath)) { Load(filePath, out languages, out dataTable); treeView.TotalReload(); } rect.x += rect.width + lineSpace; rect.width = 300; searchText = searchField.OnGUI(rect, searchText); if (searchField.HasFocus() && Event.current.rawType == EventType.KeyUp && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter)) { treeView.Filtter(searchText, searchFlags); searchField.SetFocus(); } rect.x += 300; rect.width = 100; searchFlags = EditorGUI.MaskField(rect, searchFlags, searchTypes); rect.x += 110; rect.width = 20; GUI.Button(rect, new GUIContent("?", "Alt + A : 增加条目\nCtrl + C : 复制条目(不支持多选复制)\nCtrl + V : 粘贴条目\nCtrl + D : 粘贴选中条目(不支持多选)\n右键显示菜单")); treeView.OnGUI(new Rect(lineSpace, 50, position.width - 10, position.height - 55)); }
public override void OnGUI(Rect rect) { EditorGUI.BeginChangeCheck(); m_connectionTreeView.search = m_SearchField.OnGUI(new Rect(rect.x + ConnectionDropDownStyles.searchFieldPadding, rect.y + ConnectionDropDownStyles.searchFieldPadding, rect.width - (2 * ConnectionDropDownStyles.searchFieldPadding), EditorGUI.kSingleLineHeight), m_connectionTreeView.search); if (!didFocus && !m_SearchField.HasFocus()) { m_SearchField.SetFocus(); didFocus = true; } if (EditorGUI.EndChangeCheck()) { if (!string.IsNullOrEmpty(m_connectionTreeView.search)) { if (!searching) { var rows = m_connectionTreeView.GetRows(); m_expandedState.Clear(); foreach (var row in rows) { m_expandedState.Add(row.id, m_connectionTreeView.IsExpanded(row.id)); } } m_connectionTreeView.ExpandAll(); searching = true; } else { if (searching) { foreach (var b in m_expandedState) { m_connectionTreeView.SetExpanded(b.Key, b.Value); } searching = false; } } Reload(); } rect.y += EditorGUI.kSingleLineHeight + ConnectionDropDownStyles.searchFieldVerticalSpacing; if (consoleAttachToPlayerState != null) { rect.y += searchToLoggingPadding; EditorGUI.BeginChangeCheck(); GUI.Toggle(new Rect(rect.x + ConnectionDropDownStyles.searchFieldPadding, rect.y, rect.width, EditorGUI.kSingleLineHeight), consoleAttachToPlayerState.IsConnected(), ConnectionUIHelper.Content.PlayerLogging); if (EditorGUI.EndChangeCheck()) { consoleAttachToPlayerState.PlayerLoggingOptionSelected(); } rect.y += EditorGUI.kSingleLineHeight + loggingVerticalPadding; GUI.enabled = consoleAttachToPlayerState.IsConnected(); m_connectionTreeView.dropDownItems.ForEach(x => x.m_Disabled = !GUI.enabled); EditorGUI.BeginChangeCheck(); GUI.Toggle(new Rect(rect.x + ConnectionDropDownStyles.searchFieldPadding, rect.y, rect.width, EditorGUI.kSingleLineHeight), consoleAttachToPlayerState.IsLoggingFullLog(), ConnectionUIHelper.Content.FullLog); if (EditorGUI.EndChangeCheck()) { consoleAttachToPlayerState.FullLogOptionSelected(); } rect.y += EditorGUI.kSingleLineHeight + loggingVerticalPadding; } m_connectionTreeView?.OnGUI(new Rect(rect.x, rect.y, rect.width, (float)m_connectionTreeView?.totalHeight)); rect.y += (float)m_connectionTreeView?.totalHeight; GUI.enabled = true; EditorGUI.DrawDelimiterLine(new Rect(rect.x, rect.y, rect.width, 1f)); rect.y += 1f; rect.y += ConnectionDropDownStyles.troubleShootBtnPadding / 2f; if (EditorGUI.Button(rect, Content.TroubleShoot, ConnectionDropDownStyles.sConnectionTrouble)) { var version = $"{Application.unityVersionVer}.{Application.unityVersionMaj}"; Application.OpenURL($"https://docs.unity3d.com/{version}/Documentation/Manual/profiler-profiling-applications.html"); } if (Event.current.type == EventType.MouseMove) { Event.current.Use(); } }
public override void OnOpen() { m_SearchField.SetFocus(); base.OnOpen(); }
private void OnEnable() { searchField = new SearchField(); searchField.SetFocus(); typeListView = new ComponentTypeListView(new TreeViewState(), types, typeSelections, ComponentFilterChanged); }