Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
                        }
                    }
                }
            }
        }