Beispiel #1
0
        protected virtual void DrawNodeSlot(NodeModifier node, Rect nodeRect)
        {
            #region Event drag connection line
            if (Event.current != null)
            {
                if (Tools.IsValidMouseAABB(nodeRect))
                {
                    _currentHover = node;

                    Rect     leftRect  = Tools.CalcLeftLinkRect(nodeRect);
                    Rect     rightRect = Tools.CalcRightLinkRect(nodeRect);
                    GUIStyle inStyle   = new GUIStyle();
                    GUIStyle outStyle  = new GUIStyle();
                    inStyle.alignment  = TextAnchor.MiddleLeft;
                    outStyle.alignment = TextAnchor.MiddleRight;

                    GUI.Box(leftRect, node.Parent == null ? ResourcesManager.GetInstance.texInputSlot : ResourcesManager.GetInstance.texInputSlotActive, inStyle);
                    GUI.Box(rightRect, node.NextNodes.Length < 1 ? ResourcesManager.GetInstance.texOutputSlot : ResourcesManager.GetInstance.texOutputSlotActive, outStyle);

                    //Connect
                    if (Event.current.type == EventType.MouseDown && Tools.IsValidMouseAABB(rightRect))
                    {
                        _isConnecting    = true;
                        _currentNode     = node;
                        _currentNodeRect = nodeRect;
                    }
                    //ReConnect
                    if (Event.current.type == EventType.MouseDown && Tools.IsValidMouseAABB(leftRect))
                    {
                        if (node.HaveParent)
                        {
                            _isConnecting = true;
                            _currentNode  = node.Parent as NodeModifier;
                            Vector2 realPos = CalcRealPosition(_currentNode._position);
                            _currentNodeRect = Tools.GetNodeRect(realPos);
                            NodeModifier.SetToDefaltContent(node);
                            //node.DeleteParent();
                        }
                    }
                }
            }
            #endregion
        }
Beispiel #2
0
        private void ShowLeftSliderArea()
        {
            Rect background = new Rect(0, _window._topHeight, _window._leftWidth, _window._windowRect.height);

            GUI.Box(background, "", ResourcesManager.GetInstance.StyleBackground);

            _leftScrollPosition = GUI.BeginScrollView(new Rect(0, _window._topHeight, _window._leftWidth, _window._windowRect.height - _window._topHeight), _leftScrollPosition, new Rect(0, _window._topHeight, _window._leftWidth - 30, /*_window._windowRect.height - */ _window._topHeight + _heightLeft), false, true, ResourcesManager.GetInstance.skin.horizontalScrollbar, ResourcesManager.GetInstance.skin.verticalScrollbar);

            _heightLeft = _window._topHeight + 5;

            if (_currentNode != null)
            {
                #region Modify Name
                EditorGUI.LabelField(GetGUILeftScrollAreaRect(50, 18, false), "Name: ");
                Rect editNameRect = GetGUILeftScrollAreaRect(50, 150, 18);// new Rect(50, _heightLeft, 150, 18);

                string oldName = _currentNode._name;
                EditorGUI.BeginChangeCheck();
                _currentNode._name = EditorGUI.TextField(editNameRect, _currentNode._name);
                if (EditorGUI.EndChangeCheck())
                {
                    OnNodeNameChange(_currentNode, oldName);
                }

                if (Event.current != null)
                {
                    if (Event.current.button == 0)
                    {
                        //Debug.Log(Event.current.type);
                        if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.Ignore)
                        {
                            //Debug.Log(Event.current.type);
                            GUI.FocusControl("Name: ");
                        }
                    }
                }
                #endregion

                #region Next Nodes
                NodeModifier[] nodes = _currentNode.NextNodes;
                if (nodes.Length > 0)
                {
                    LeftHeightSpace(5);
                    GUIStyle style = new GUIStyle();
                    style.normal.textColor = Color.white;
                    style.fontSize         = 14;
                    EditorGUI.LabelField(GetGUILeftScrollAreaRect(_window._leftWidth, 30), "Next Nodes:", style);
                    for (int i = 0; i < nodes.Length; i++)
                    {
                        Rect rect = GetGUILeftScrollAreaRect(_window._leftWidth, 20, false);
                        EditorGUI.LabelField(rect, nodes[i]._name);
                        if (GUI.Button(GetGUILeftScrollAreaRect(_window._leftWidth - 68f, 50f, 20f), "<color=red>Delete</color>", ResourcesManager.GetInstance.skin.button))
                        {
                            if (nodes[i].Parent == _currentNode)
                            {
                                NodeModifier.SetToDefaltContent(nodes[i]);
                            }
                            else
                            {
                                _currentNode.Remove(nodes[i]);
                            }
                            break;
                        }
                    }
                }
                #endregion

                LeftHeightSpace(10);

                DrawLeftArribute(_currentNode);
            }


            GUI.EndScrollView();
        }