Пример #1
0
        protected void LinkCurrentNode()
        {
            //强制链接单节点
            if (Event.current.control)
            {
                _currentNode.AddNextNode(_currentHover);
                return;
            }

            if (!_currentHover.CanSetParent(_currentNode))
            {
                //if (_currentNode.IsParent(_currentHover))
                if (!_currentNode.HaveParentNodeInNext())
                {
                    _currentNode.AddNextNode(_currentHover);
                    return;
                }

                EditorUtility.DisplayDialog("Error", "Not allow connect to twice parent! You must break one connect with parent and then change it.", "OK");
                return;
            }

            if (NodeModifier.SetParent(_currentHover, _currentNode))
            {
                OnLinkNode(_currentNode, _currentHover);
            }
        }
Пример #2
0
        private void ShowConnectLine()
        {
            if (_isConnecting && _currentNode != null)
            {
                Vector2 pos1 = new Vector2(_currentNodeRect.max.x, _currentNodeRect.max.y - Tools.NodeHalfHeightZoomed);
                Tools.DrawBazier(pos1, Event.current.mousePosition);
                if (Tools.MouseUp)
                {
                    _isConnecting = false;
                    if (_currentNode == _currentHover)
                    {
                        return;
                    }
                    if (Tools.IsValidMouseAABB(Tools.GetNodeRect(CalcRealPosition(_currentHover._position))))
                    {
                        //强制链接单节点
                        if (Event.current.control)
                        {
                            _currentNode.AddNextNode(_currentHover);
                            return;
                        }

                        if (!_currentHover.CanSetParent(_currentNode))
                        {
                            //if (_currentNode.IsParent(_currentHover))
                            if (!_currentNode.HaveParentNodeInNext())
                            {
                                _currentNode.AddNextNode(_currentHover);
                                return;
                            }

                            EditorUtility.DisplayDialog("Error", "Not allow connect to twice parent! You must break one connect with parent and then change it.", "OK");
                            return;
                        }

                        if (NodeModifier.SetParent(_currentHover, _currentNode))
                        {
                            OnLinkNode(_currentNode, _currentHover);
                        }
                    }
                }
            }
        }
Пример #3
0
        protected void DuplicateNode(NodeModifier targetNode)
        {
            NodeModifier node = ReflectionHelper.CreateInstance <NodeModifier>(targetNode.GetType().FullName);

            JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(targetNode), node);
            node._position = new Vector2(node._position.x + 10, node._position.y + 10);
            if (targetNode.Parent != null)
            {
                NodeModifier.SetParent(node, targetNode.Parent);
            }
            else if (targetNode.Content != null)
            {
                NodeModifier.SetContent(node, targetNode.Content);
            }

            DragModifier d = node.GetContent() as DragModifier;

            node.SetID(d.GenerateID());
        }