public List <SearchTreeEntry> CreateSearchTree(SearchWindowContext context) { var tree = new List <SearchTreeEntry>(); // First item is the title of the window tree.Add(new SearchTreeGroupEntry(new GUIContent("Add Node"), 0)); // TODO: Custom top level pieces (Comments, new variables, etc) // Construct a tree of available nodes by module path var nodes = NodeReflection.GetNodeTypes(); var groups = new SearchGroup(1); foreach (var node in nodes.Values) { var path = node.path; // Skip the node if it the module isn't whitelisted if (!IsInSupportedModule(path)) { continue; } // If we're coming from a port, make sure to only add nodes that accept // an input (or output) that's compatible. if (connectedPort == null || IsCompatibleWithConnectedPort(node)) { var group = groups; if (path != null) { for (int i = 0; i < path.Length; i++) { if (!group.subgroups.ContainsKey(path[i])) { group.subgroups.Add(path[i], new SearchGroup(group.depth + 1)); } group = group.subgroups[path[i]]; } } group.nodes.Add(node); } } groups.AddToTree(tree); return(tree); }
protected void OnTooltip(TooltipEvent evt) { // TODO: Better implementation that can be styled if (evt.target == titleContainer.Q("title-label")) { var typeData = NodeReflection.GetNodeType(target.GetType()); evt.tooltip = typeData?.tooltip; // Float the tooltip above the node title bar var bound = titleContainer.worldBound; bound.x = 0; bound.y = 0; bound.height *= -1; evt.rect = titleContainer.LocalToWorld(bound); } }