Beispiel #1
0
        public virtual IEnumerable <KeyValuePair <string, Type> > FilterCreateNodeMenuEntries()
        {
            // By default we don't filter anything
            foreach (var nodeMenuItem in NodeProvider.GetNodeMenuEntries())
            {
                yield return(nodeMenuItem);
            }

            // TODO: add exposed properties to this list
        }
Beispiel #2
0
        void CreateEdgeNodeMenu(List <SearchTreeEntry> tree)
        {
            var entries = NodeProvider.GetEdgeCreationNodeMenuEntry((edgeFilter.input ?? edgeFilter.output) as PortView);

            var titlePaths = new HashSet <string>();

            var nodePaths = NodeProvider.GetNodeMenuEntries();

            tree.Add(new SearchTreeEntry(new GUIContent($"Relay", icon))
            {
                level    = 1,
                userData = new NodeProvider.PortDescription {
                    nodeType        = typeof(RelayNode),
                    portType        = typeof(System.Object),
                    isInput         = inputPortView != null,
                    portFieldName   = inputPortView != null ? nameof(RelayNode.output) : nameof(RelayNode.input),
                    portIdentifier  = "0",
                    portDisplayName = inputPortView != null ? "Out" : "In",
                }
            });

            foreach (var nodeMenuItem in entries.OrderBy(n => n.nodeType.ToString()))
            {
                var nodePath = nodePaths.FirstOrDefault(kp => kp.Value.nodeType == nodeMenuItem.nodeType).Key;

                // Ignore the node if it's not in the create menu
                if (String.IsNullOrEmpty(nodePath))
                {
                    continue;
                }

                var nodeName = nodePath;
                var level    = 0;
                var parts    = nodePath.Split('/');

                if (parts.Length > 1)
                {
                    level++;
                    nodeName = parts[parts.Length - 1];
                    var fullTitleAsPath = "";

                    for (var i = 0; i < parts.Length - 1; i++)
                    {
                        var title = parts[i];
                        fullTitleAsPath += title;
                        level            = i + 1;

                        // Add section title if the node is in subcategory
                        if (!titlePaths.Contains(fullTitleAsPath))
                        {
                            tree.Add(new SearchTreeGroupEntry(new GUIContent(title))
                            {
                                level = level
                            });
                            titlePaths.Add(fullTitleAsPath);
                        }
                    }
                }

                tree.Add(new SearchTreeEntry(new GUIContent($"{nodeName}:  {nodeMenuItem.portDisplayName}", icon))
                {
                    level    = level + 1,
                    userData = nodeMenuItem
                });
            }
        }