예제 #1
0
        public PropertyNodeView(PropertyNode node, EdgeConnectorListener edgeConnectorListener)
            : base(null, ShaderPort.Create(node.GetOutputSlots <MaterialSlot>().First(), edgeConnectorListener))
        {
            styleSheets.Add(Resources.Load <StyleSheet>("Styles/PropertyNodeView"));
            this.node   = node;
            viewDataKey = node.objectId.ToString();
            userData    = node;

            // Getting the generatePropertyBlock property to see if it is exposed or not
            var graph    = node.owner as GraphData;
            var property = node.property;
            var icon     = (graph.isSubGraph || (property.isExposable && property.generatePropertyBlock)) ? exposedIcon : null;

            this.icon = icon;

            // Setting the position of the node, otherwise it ends up in the center of the canvas
            SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0));

            // Removing the title label since it is not used and taking up space
            this.Q("title-label").RemoveFromHierarchy();

            // Add disabled overlay
            Add(new VisualElement()
            {
                name = "disabledOverlay", pickingMode = PickingMode.Ignore
            });

            // Update active state
            SetActive(node.isActive);

            // Registering the hovering callbacks for highlighting
            RegisterCallback <MouseEnterEvent>(OnMouseHover);
            RegisterCallback <MouseLeaveEvent>(OnMouseHover);
        }
예제 #2
0
        public void AddSlots(IEnumerable <MaterialSlot> slots)
        {
            foreach (var slot in slots)
            {
                if (slot.hidden)
                {
                    continue;
                }

                var port = ShaderPort.Create(slot, m_ConnectorListener);

                if (slot.isOutputSlot)
                {
                    outputContainer.Add(port);
                }
                else
                {
                    inputContainer.Add(port);
                }
            }
        }
예제 #3
0
        public PropertyNodeView(PropertyNode node, EdgeConnectorListener edgeConnectorListener)
            : base(null, ShaderPort.Create(node.GetOutputSlots <MaterialSlot>().First(), edgeConnectorListener))
        {
            styleSheets.Add(Resources.Load <StyleSheet>("Styles/PropertyNodeView"));
            this.node   = node;
            viewDataKey = node.objectId.ToString();
            userData    = node;

            // Getting the generatePropertyBlock property to see if it is exposed or not
            UpdateIcon();

            // Setting the position of the node, otherwise it ends up in the center of the canvas
            SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0));

            // Removing the title label since it is not used and taking up space
            this.Q("title-label").RemoveFromHierarchy();

            // Add disabled overlay
            Add(new VisualElement()
            {
                name = "disabledOverlay", pickingMode = PickingMode.Ignore
            });

            // Update active state
            SetActive(node.isActive);

            // Registering the hovering callbacks for highlighting
            RegisterCallback <MouseEnterEvent>(OnMouseHover);
            RegisterCallback <MouseLeaveEvent>(OnMouseHover);

            // add the right click context menu
            IManipulator contextMenuManipulator = new ContextualMenuManipulator(AddContextMenuOptions);

            this.AddManipulator(contextMenuManipulator);

            // Set callback association for display name updates
            property.displayNameUpdateTrigger += node.UpdateNodeDisplayName;
        }
예제 #4
0
        public PropertyNodeView(PropertyNode node, EdgeConnectorListener edgeConnectorListener)
            : base(null, ShaderPort.Create(node.GetOutputSlots <MaterialSlot>().First(), edgeConnectorListener))
        {
            styleSheets.Add(Resources.Load <StyleSheet>("Styles/PropertyNodeView"));
            this.node = node;
            userData  = node;

            // Getting the generatePropertyBlock property to see if it is exposed or not
            var graph    = node.owner as GraphData;
            var property = graph.properties.FirstOrDefault(x => x.guid == node.propertyGuid);
            var icon     = property.generatePropertyBlock ? exposedIcon : null;

            this.icon = icon;

            // Setting the position of the node, otherwise it ends up in the center of the canvas
            SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0));

            // Removing the title label since it is not used and taking up space
            this.Q("title-label").RemoveFromHierarchy();

            // Registering the hovering callbacks for highlighting
            RegisterCallback <MouseEnterEvent>(OnMouseHover);
            RegisterCallback <MouseLeaveEvent>(OnMouseHover);
        }
예제 #5
0
 public bool FindPort(SlotReference slot, out ShaderPort port)
 {
     port = output as ShaderPort;
     return(port != null && port.slot.slotReference.Equals(slot));
 }
예제 #6
0
 public bool FindPort(SlotReference slot, out ShaderPort port)
 {
     port = contentContainer.Q("top")?.Query <ShaderPort>().Where(p => p.slot.slotReference.Equals(slot)).First();
     return(port != null);
 }