Beispiel #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);
        }
        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;
        }
Beispiel #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;
            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);
        }