Example #1
0
            void OnInputChanged(string searchString)
            {
                _assemblySearch.ClearResults();

                if (string.IsNullOrEmpty(searchString))
                {
                    _selectedAssemblies = null;
                    _selectedTypes      = null;
                    return;
                }

                if (_assemblyCache == null)
                {
                    _assemblyCache = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic).ToArray();
                }

                var results = new List <string>();

                _selectedAssemblies = _assemblyCache.Where(a =>
                                                           a.GetName().Name.StartsWith(_assemblySearch.searchString,
                                                                                       StringComparison.InvariantCultureIgnoreCase) ||
                                                           _assemblySearch.searchString.StartsWith(a.GetName().Name,
                                                                                                   StringComparison.InvariantCultureIgnoreCase)).ToList();

                if (_selectedAssemblies.Count > 1)
                {
                    results.AddRange(_selectedAssemblies.Select(assembly => assembly.GetName().Name));
                }

                if (searchString.StartsWith("System", StringComparison.InvariantCultureIgnoreCase))
                {
                    // add mscorlib (the System namespace is there)
                    _selectedAssemblies.Add(typeof(int).Assembly);
                }

                if (searchString.Length > 3)
                {
                    _selectedTypes = _selectedAssemblies.SelectMany(a => a.GetExportedTypes()).Where(t =>
                                                                                                     t.FullName != null &&
                                                                                                     t.FullName.StartsWith(searchString, StringComparison.InvariantCultureIgnoreCase)).ToArray();

                    results.AddRange(_selectedTypes.Select(type => type.FullName));
                }

                results.Sort();

                foreach (var searchResult in results.Distinct())
                {
                    _assemblySearch.AddResult(searchResult);
                }
            }
 void OnInputChanged(string searchString)
 {
     autocompleteSearchField.ClearResults();
     if (searchString != null)
     {
         foreach (var entity in languageListObj.languageList[viewIndex - 1].words)
         {
             if (entity.Key.StartsWith(searchString))
             {
                 autocompleteSearchField.AddResult(entity.Key);
             }
         }
     }
 }
Example #3
0
        // public override void AddContextMenuItems(GenericMenu menu)
        // {
        //     if (NodeEditorWindow.mode == NodeEditorMode.Runtime)
        //         return;

        //     Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition);
        //     for (int i = 0; i < BTEditorDefine.NodeCfgs.Count; ++i)
        //     {
        //         FTNodeCfg cfgNode = BTEditorDefine.NodeCfgs[i];
        //         string path = cfgNode.path;

        //         menu.AddItem(new GUIContent(path), false, () =>
        //         {
        //             FTNode node = (FTNode)CreateNode(typeof(FTNode), pos);
        //             NodeEditorWindow.current.AutoConnect(node);
        //             node.InitWhenAddFromGraph(cfgNode);
        //         });
        //     }

        //     // NOTE:
        //     // because copy/paste will create same id Node, so temp disable them
        //     menu.AddSeparator("");
        //     menu.AddItem(new GUIContent("Copy"), false, () => {
        //         NodeEditorWindow.current.CopySelectedNodes();
        //     });
        //     if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0)
        //     {
        //         menu.AddItem(new GUIContent("Paste"), false, () => {
        //             NodeEditorWindow.current.PasteNodes(pos);
        //             var newNodes = Selection.objects;
        //             if (newNodes != null)
        //             {
        //                 for (int i = 0; i < newNodes.Length; ++i)
        //                 {
        //                     var FTNode = newNodes[i] as FTNode;
        //                     if (FTNode != null)
        //                         FTNode.id = BTEditorUtils.NewGuid();
        //                 }
        //             }
        //         });
        //     }
        //     else
        //         menu.AddDisabledItem(new GUIContent("Paste"));
        //     // menu.AddItem(new GUIContent("Preferences"), false, () => NodeEditorReflection.OpenPreferences());
        //     // menu.AddCustomContextMenuItems(target);

        //     // menu.AddSeparator("");
        //     menu.AddItem(new GUIContent("Group"), false, () =>
        //     {
        //         var group = (XNode.NodeGroups.NodeGroup)CreateNode(typeof(XNode.NodeGroups.NodeGroup), pos);
        //         NodeEditorWindow.current.AutoConnect(group);
        //     });

        //     // self define
        //     var selfNodePaths = BTSettings.Default.selfNodePaths;
        //     if (selfNodePaths != null && selfNodePaths.Length > 0)
        //     {
        //         menu.AddSeparator("");
        //         for (int i = 0; i < selfNodePaths.Length; ++i)
        //         {
        //             string path = selfNodePaths[i];
        //             if (string.IsNullOrEmpty(path))
        //                 continue;

        //             menu.AddItem(new GUIContent(path), false, () =>
        //             {
        //                 var pinfos = path.Split('/');
        //                 if (pinfos == null)
        //                 {
        //                     Debug.LogError("BT-- parse self bt node path failed > " + path);
        //                     return;
        //                 }
        //                 string nodeName = pinfos[pinfos.Length - 1];
        //                 var nodeCfg = BTEditorDefine.GetFTNodeCfg(nodeName);
        //                 if (nodeCfg == null)
        //                 {
        //                     Debug.LogError("BT-- parse self bt node path failed > " + path);
        //                     return;
        //                 }

        //                 FTNode node = (FTNode)CreateNode(typeof(FTNode), pos);
        //                 NodeEditorWindow.current.AutoConnect(node);
        //                 node.InitWhenAddFromGraph(nodeCfg);
        //             });
        //         }
        //     }
        // }

        void OnNodeSearchFieldInputChanged(string searchString)
        {
            searchString = searchString.Trim();

            nodeSearchField.ClearResults();
            if (!string.IsNullOrEmpty(searchString))
            {
                for (int i = 0; i < nodeSearchPaths.Count; ++i)
                {
                    string path = nodeSearchPaths[i].ToLower();
                    if (path.Contains(searchString.ToLower()))
                    {
                        nodeSearchField.AddResult(nodeSearchPaths[i]);
                    }
                }
            }
        }