Example #1
0
        public NodePort(BaseNode owner, string fieldName)
        {
            this.fieldName = fieldName;
            this.owner     = owner;

            ourValueField = owner.GetType().GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            customPortIOMethod = CustomPortIO.GetCustomPortMethod(owner.GetType(), fieldName);
        }
Example #2
0
        void InitializeView()
        {
            controlsContainer = new VisualElement {
                name = "controls"
            };
            controlsContainer.AddToClassList("NodeControls");
            mainContainer.Add(controlsContainer);

            rightTitleContainer = new VisualElement {
                name = "RightTitleContainer"
            };
            titleContainer.Add(rightTitleContainer);

            if (nodeTarget.showControlsOnHover)
            {
                bool mouseOverControls = false;
                controlsContainer.style.display = DisplayStyle.None;
                RegisterCallback <MouseOverEvent>(e => {
                    controlsContainer.style.display = DisplayStyle.Flex;
                    mouseOverControls = true;
                });
                RegisterCallback <MouseOutEvent>(e => {
                    var rect = GetPosition();
                    var graphMousePosition = owner.contentViewContainer.WorldToLocal(e.mousePosition);
                    if (rect.Contains(graphMousePosition) || !nodeTarget.showControlsOnHover)
                    {
                        return;
                    }
                    mouseOverControls = false;
                    schedule.Execute(_ => {
                        if (!mouseOverControls)
                        {
                            controlsContainer.style.display = DisplayStyle.None;
                        }
                    }).ExecuteLater(500);
                });
            }

            Undo.undoRedoPerformed += UpdateFieldValues;

            debugContainer = new VisualElement {
                name = "debug"
            };
            if (nodeTarget.debug)
            {
                mainContainer.Add(debugContainer);
            }

            title = (string.IsNullOrEmpty(nodeTarget.name)) ? nodeTarget.GetType().Name : nodeTarget.name;

            initializing = true;

            SetPosition(nodeTarget.position);
            SetNodeColor(nodeTarget.color);

            AddInputContainer();
        }
Example #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="owner">owner node</param>
        /// <param name="fieldName">the C# property name</param>
        /// <param name="portData">Data of the port</param>
        public NodePort(BaseNode owner, string fieldName, PortData portData)
        {
            this.fieldName = fieldName;
            this.owner     = owner;
            this.portData  = portData;

            fieldInfo = owner.GetType().GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            customPortIOMethod = CustomPortIO.GetCustomPortMethod(owner.GetType(), fieldName);
        }
Example #4
0
        void InitializeView()
        {
            controlsContainer = new VisualElement {
                name = "controls"
            };
            mainContainer.Add(controlsContainer);

            debugContainer = new VisualElement {
                name = "debug"
            };
            mainContainer.Add(debugContainer);

            title = (string.IsNullOrEmpty(nodeTarget.name)) ? nodeTarget.GetType().Name : nodeTarget.name;

            SetPosition(nodeTarget.position);
        }
Example #5
0
        protected BaseNodeView AddNodeView(BaseNode node)
        {
            var viewType = NodeProvider.GetNodeViewTypeFromType(node.GetType());

            if (viewType == null)
            {
                viewType = typeof(BaseNodeView);
            }

            var baseNodeView = Activator.CreateInstance(viewType) as BaseNodeView;

            baseNodeView.Initialize(this, node);
            AddElement(baseNodeView);

            nodeViews.Add(baseNodeView);
            nodeViewsPerNode[node] = baseNodeView;

            return(baseNodeView);
        }
 void UpdateTitle()
 {
     title = (nodeTarget.GetCustomName() == null) ? nodeTarget.GetType().Name : nodeTarget.GetCustomName();
 }
Example #7
0
        void InitializeView()
        {
            controlsContainer = new VisualElement {
                name = "controls"
            };
            mainContainer.parent.name = nodeTarget.GUID;
            mainContainer.Add(controlsContainer);

            if (nodeTarget.showControlsOnHover)
            {
                bool mouseOverControls = false;
                controlsContainer.style.display = DisplayStyle.None;
                RegisterCallback <MouseOverEvent>(e => {
                    controlsContainer.style.display = DisplayStyle.Flex;
                    mouseOverControls = true;
                });
                RegisterCallback <MouseOutEvent>(e => {
                    var rect = GetPosition();
                    var graphMousePosition = owner.contentViewContainer.WorldToLocal(e.mousePosition);
                    if (rect.Contains(graphMousePosition) || !nodeTarget.showControlsOnHover)
                    {
                        return;
                    }
                    mouseOverControls = false;
                    schedule.Execute(_ => {
                        if (!mouseOverControls)
                        {
                            controlsContainer.style.display = DisplayStyle.None;
                        }
                    }).ExecuteLater(500);
                });
            }

            Undo.undoRedoPerformed += UpdateFieldValues;
            //
            // debugContainer = new VisualElement{ name = "debug" };
            // if (nodeTarget.debug)
            //  mainContainer.Add(debugContainer);

            title = (string.IsNullOrEmpty(nodeTarget.name)) ? nodeTarget.GetType().Name : nodeTarget.name;
            titleContainer.tooltip = title;

            if (!string.IsNullOrEmpty(nodeTarget.category))
            {
                var categoryLabel = new Label(nodeTarget.category)
                {
                    name = "category"
                };
                mainContainer.parent.Add(categoryLabel);
                categoryLabel.SendToBack();
                categoryLabel.pickingMode = PickingMode.Ignore;
            }

            initializing = true;

            SetPosition(nodeTarget.position);

            if (nodeTarget is IConditionalNode)
            {
                mainContainer.parent.AddToClassList("conditional-node");

                var previousLink = contentContainer.Q(className: "executed");
                if (previousLink != null)
                {
                    titleContainer.Add(previousLink);
                    previousLink.SendToBack();
                }

                if (nodeTarget is LinearConditionalNode)
                {
                    mainContainer.parent.AddToClassList("executes-next");
                    var nextLink = contentContainer.Q(className: "executes");
                    titleContainer.Add(nextLink);
                }
            }

            if (nodeTarget.headerClass != "")
            {
                titleContainer.AddToClassList(nodeTarget.headerClass);
            }

            if (nodeTarget.nodeClass != "")
            {
                contentContainer.AddToClassList(nodeTarget.nodeClass);
            }
        }