Пример #1
0
        public override void Initialize(UGraphView owner, NodeComponent node)
        {
            this.owner      = owner;
            this.targetNode = node;
            title           = targetNode.GetNodeName();
            titleButtonContainer.RemoveFromHierarchy();

            this.AddStyleSheet("uNodeStyles/NativeStickyNote");
            AddToClassList("sticky-note");

            comment = new Label(node.comment);
            inputContainer.Add(comment);
            elementTypeColor = Color.yellow;

            titleContainer.RegisterCallback <MouseDownEvent>((e) => {
                if (e.clickCount == 2)
                {
                    ActionPopupWindow.ShowWindow(Vector2.zero, node.gameObject.name,
                                                 (ref object obj) => {
                        object str = EditorGUILayout.TextField(obj as string);
                        if (obj != str)
                        {
                            obj = str;
                            node.gameObject.name = obj as string;
                            if (GUI.changed)
                            {
                                uNodeGUIUtility.GUIChanged(node);
                            }
                        }
                    }).ChangePosition(owner.GetTopMousePosition(e)).headerName = "Rename title";
                }
            });
            comment.RegisterCallback <MouseDownEvent>((e) => {
                if (e.clickCount == 2)
                {
                    ActionPopupWindow.ShowWindow(Vector2.zero, node.comment,
                                                 (ref object obj) => {
                        object str = EditorGUILayout.TextArea(obj as string);
                        if (obj != str)
                        {
                            obj          = str;
                            node.comment = obj as string;
                            if (GUI.changed)
                            {
                                uNodeGUIUtility.GUIChanged(node);
                            }
                        }
                    }, 300, 200).ChangePosition(owner.GetTopMousePosition(e)).headerName = "Edit description";
                }
            });

            //this.SetSize(new Vector2(node.editorRect.width, node.editorRect.height));
            SetPosition(targetNode.editorRect);
            RefreshPorts();
        }
Пример #2
0
        public virtual void Initialize(UGraphView owner, TransitionEvent transition)
        {
            this.transition = transition;
            AddToClassList("transition");
            this.AddStyleSheet("uNodeStyles/NativeNodeStyle");
            this.AddStyleSheet(UIElementUtility.Theme.nodeStyle);
            Initialize(owner);
            ReloadView();

            border.style.overflow = Overflow.Visible;

            titleIcon.RemoveFromHierarchy();
            m_CollapseButton.RemoveFromHierarchy();

            RegisterCallback <MouseDownEvent>((e) => {
                if (e.button == 0 && e.clickCount == 2)
                {
                    ActionPopupWindow.ShowWindow(owner.GetTopMousePosition(e), transition.Name,
                                                 (ref object obj) => {
                        object str = EditorGUILayout.TextField(obj as string);
                        if (obj != str)
                        {
                            obj             = str;
                            transition.Name = obj as string;
                            if (GUI.changed)
                            {
                                uNodeGUIUtility.GUIChanged(transition);
                            }
                        }
                    }).headerName = "Edit name";
                }
            });
        }
Пример #3
0
        public override void Initialize(UGraphView owner, NodeComponent node)
        {
            this.owner = owner;
            targetNode = node;
            title      = targetNode.GetNodeName();
            titleButtonContainer.RemoveFromHierarchy();
            this.AddStyleSheet("uNodeStyles/NativeRegionStyle");
            var border = this.Q("node-border");

            border.style.overflow = Overflow.Visible;
            horizontalDivider     = border.Q("contents").Q("divider");

            comment = new Label(node.comment);
            inputContainer.Add(comment);

            titleContainer.RegisterCallback <MouseDownEvent>((e) => {
                if (e.clickCount == 2 && e.button == 0)
                {
                    ActionPopupWindow.ShowWindow(Vector2.zero, node.gameObject.name,
                                                 (ref object obj) => {
                        object str = EditorGUILayout.TextField(obj as string);
                        if (obj != str)
                        {
                            obj = str;
                            node.gameObject.name = obj as string;
                            if (GUI.changed)
                            {
                                uNodeGUIUtility.GUIChanged(node);
                            }
                        }
                    }).ChangePosition(owner.GetTopMousePosition(e)).headerName = "Rename title";
                }
            });
            RegisterCallback <MouseDownEvent>((e) => {
                if (e.button == 0)
                {
                    nodes = new List <NodeComponent>(owner.graph.nodes);
                    if (owner.graph.eventNodes != null)
                    {
                        foreach (var c in owner.graph.eventNodes)
                        {
                            if (c != null)
                            {
                                nodes.Add(c);
                            }
                        }
                    }
                    nodes.RemoveAll((n) => n == null || !targetNode.editorRect.Contains(new Vector2(n.editorRect.x + (n.editorRect.width * 0.5f), n.editorRect.y + (n.editorRect.height * 0.5f))));
                }
            });

            Add(new ResizableElement());
            this.SetSize(new Vector2(node.editorRect.width, node.editorRect.height));
            Teleport(targetNode.editorRect);
            ReloadView();
            RefreshPorts();
        }