Ejemplo n.º 1
0
        void AddNode(INode node)
        {
            var nodeView = new MaterialNodeView {
                userData = node
            };

            m_GraphView.AddElement(nodeView);
            nodeView.Initialize(node as AbstractMaterialNode, m_PreviewManager, m_EdgeConnectorListener);
            node.RegisterCallback(OnNodeChanged);
            nodeView.MarkDirtyRepaint();

            if (m_SearchWindowProvider.nodeNeedsRepositioning && m_SearchWindowProvider.targetSlotReference.nodeGuid.Equals(node.guid))
            {
                m_SearchWindowProvider.nodeNeedsRepositioning = false;
                foreach (var element in nodeView.inputContainer.Union(nodeView.outputContainer))
                {
                    var port = element as ShaderPort;
                    if (port == null)
                    {
                        continue;
                    }
                    if (port.slot.slotReference.Equals(m_SearchWindowProvider.targetSlotReference))
                    {
                        port.RegisterCallback <GeometryChangedEvent>(RepositionNode);
                        return;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void AddNode(AbstractMaterialNode node)
        {
            var  materialNode = (AbstractMaterialNode)node;
            Node nodeView;

            if (node is PropertyNode propertyNode)
            {
                var tokenNode = new PropertyNodeView(propertyNode, m_EdgeConnectorListener);
                m_GraphView.AddElement(tokenNode);
                nodeView = tokenNode;
            }
            else
            {
                var materialNodeView = new MaterialNodeView {
                    userData = materialNode
                };
                m_GraphView.AddElement(materialNodeView);
                materialNodeView.Initialize(materialNode, m_PreviewManager, m_EdgeConnectorListener);
                nodeView = materialNodeView;
            }

            node.RegisterCallback(OnNodeChanged);
            nodeView.MarkDirtyRepaint();

            if (m_SearchWindowProvider.nodeNeedsRepositioning && m_SearchWindowProvider.targetSlotReference.nodeGuid.Equals(node.guid))
            {
                m_SearchWindowProvider.nodeNeedsRepositioning = false;
                foreach (var element in nodeView.inputContainer.Children().Union(nodeView.outputContainer.Children()))
                {
                    var port = (ShaderPort)element;
                    if (port.slot.slotReference.Equals(m_SearchWindowProvider.targetSlotReference))
                    {
                        port.RegisterCallback <GeometryChangedEvent>(RepositionNode);
                        return;
                    }
                }
            }

            m_AddNodeGraphElements.Clear();
            m_GraphView.graphElements.ToList(m_AddNodeGraphElements);

            if (materialNode.groupGuid != Guid.Empty)
            {
                foreach (var element in m_AddNodeGraphElements)
                {
                    if (element is ShaderGroup groupView && groupView.userData.guid == materialNode.groupGuid)
                    {
                        groupView.AddElement(nodeView);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        void GroupSelection(DropdownMenuAction action)
        {
            Vector2 pos = action.eventInfo.localMousePosition;

            string    title     = "New Group";
            GroupData groupData = new GroupData(title, pos);

            graph.owner.RegisterCompleteObjectUndo("Create Group Node");
            graph.AddGroupData(groupData);

            foreach (ISelectable selectable in selection)
            {
                if (selectable is MaterialNodeView)
                {
                    MaterialNodeView     materialNodeView     = selectable as MaterialNodeView;
                    AbstractMaterialNode abstractMaterialNode = materialNodeView.node;
                    graph.SetNodeGroup(abstractMaterialNode, groupData);
                }
            }
        }