Beispiel #1
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";
                }
            });
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
0
        void OnClick(MouseUpEvent mouseDownEvent)
        {
            var val  = config.value;
            var mPos = mouseDownEvent.mousePosition;

            if (UnityEditor.EditorWindow.focusedWindow != null)
            {
                mPos = (mouseDownEvent.currentTarget as VisualElement).GetScreenMousePosition(
                    mouseDownEvent.localMousePosition,
                    UnityEditor.EditorWindow.focusedWindow);
            }
            if (config.filter.OnlyGetType)
            {
                if (config.filter.CanManipulateArray())
                {
                    TypeSelectorWindow.ShowWindow(Vector2.zero, config.filter, delegate(MemberData[] types) {
                        config.value = types[0];
                        config.OnValueChanged(config.value);
                        config.owner.OnValueChanged();
                        config.owner.MarkRepaint();
                    }, new TypeItem[1] {
                        val as MemberData
                    }).ChangePosition(mPos);
                }
                else
                {
                    ItemSelector.ShowWindow(null, val as MemberData, config.filter, (m) => {
                        config.value = m;
                        config.OnValueChanged(m);
                        config.owner.OnValueChanged();
                        config.owner.MarkRepaint();
                    }).ChangePosition(mPos);
                }
            }
            else
            {
                ActionPopupWindow.ShowWindow(Vector2.zero, () => {
                    uNodeGUIUtility.EditValueLayouted(GUIContent.none, val, config.type, (obj) => {
                        config.owner.RegisterUndo();
                        val = obj;
                        config.OnValueChanged(obj);
                        config.owner.MarkRepaint();
                    }, new uNodeUtility.EditValueSettings()
                    {
                        attributes  = new object[] { config.filter },
                        unityObject = config.owner.targetNode
                    });
                }, 300, 300).ChangePosition(mPos);
            }
        }
Beispiel #5
0
 private void Inspect(TreeViewItem treeView, Vector2 position)
 {
     if (treeView is HierarchyNodeTree nodeTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = nodeTree.node
             });
         }, 300, 300).ChangePosition(position);
     }
     else if (treeView is HierarchyFunctionTree functionTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = functionTree.function
             });
         }, 300, 300).ChangePosition(position);
     }
     else if (treeView is HierarchyPropertyTree propertyTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = propertyTree.property
             });
         }, 300, 300).ChangePosition(position);
     }
     else if (treeView is HierarchyVariableTree variableTree)
     {
         ActionPopupWindow.ShowWindow(Vector2.zero, () => {
             CustomInspector.ShowInspector(new GraphEditorData(graph)
             {
                 selected = variableTree.variable
             });
         }, 300, 300).ChangePosition(position);
     }
 }
Beispiel #6
0
        protected void Initialize(UGraphView owner)
        {
            this.owner = owner;
            this.AddToClassList("node-view");
            if (!ShowExpandButton())             //Hides colapse button
            {
                m_CollapseButton.style.position = Position.Absolute;
                m_CollapseButton.style.width    = 0;
                m_CollapseButton.style.height   = 0;
                m_CollapseButton.visible        = false;
            }
            base.expanded = true;
            RegisterCallback <MouseDownEvent>(evt => {
                var mPos = (evt.currentTarget as VisualElement).GetScreenMousePosition(evt.localMousePosition, graph.window);
                if (evt.button == 0 && evt.shiftKey && !evt.altKey)
                {
                    ActionPopupWindow.ShowWindow(Vector2.zero, () => {
                        CustomInspector.ShowInspector(new GraphEditorData(graph.editorData)
                        {
                            selected = targetNode
                        });
                    }, 300, 300).ChangePosition(mPos);
                }
            });
            RegisterCallback <MouseOverEvent>((e) => {
                for (int i = 0; i < inputPorts.Count; i++)
                {
                    var edges = inputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = true;
                        }
                    }
                }
                for (int i = 0; i < outputPorts.Count; i++)
                {
                    var edges = outputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = true;
                        }
                    }
                }
            });
            RegisterCallback <MouseLeaveEvent>((e) => {
                for (int i = 0; i < inputPorts.Count; i++)
                {
                    var edges = inputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = false;
                        }
                    }
                }
                for (int i = 0; i < outputPorts.Count; i++)
                {
                    var edges = outputPorts[i].GetEdges();
                    foreach (var edge in edges)
                    {
                        if (edge == null)
                        {
                            continue;
                        }
                        if (edge.isProxy)
                        {
                            edge.edgeControl.visible = false;
                        }
                    }
                }
            });
            RegisterCallback <GeometryChangedEvent>(evt => {
                if (evt.oldRect != Rect.zero && evt.oldRect.width != evt.newRect.width)
                {
                    Teleport(new Rect(evt.newRect.x + (evt.oldRect.width - evt.newRect.width), evt.newRect.y, evt.newRect.width, evt.newRect.height));
                }
            });

            border = this.Q("node-border");
            {            //Flow inputs
                flowInputContainer      = new VisualElement();
                flowInputContainer.name = "flow-inputs";
                flowInputContainer.AddToClassList("flow-container");
                flowInputContainer.AddToClassList("input");
                flowInputContainer.pickingMode = PickingMode.Ignore;
                border.Insert(0, flowInputContainer);
            }
            {            //Flow outputs
                flowOutputContainer      = new VisualElement();
                flowOutputContainer.name = "flow-outputs";
                flowOutputContainer.AddToClassList("flow-container");
                flowOutputContainer.AddToClassList("output");
                flowOutputContainer.pickingMode = PickingMode.Ignore;
                Add(flowOutputContainer);
            }

            controlsContainer = new VisualElement {
                name = "controls"
            };
            mainContainer.Add(controlsContainer);

            titleIcon = new Image()
            {
                name = "title-icon"
            };
            titleContainer.Add(titleIcon);
            titleIcon.SendToBack();

            OnSetup();
        }