/// <summary> /// Creates connection between one node to another. The connection is one one-way and tries to prevent circular to prevent infinity loops. /// </summary> /// <param name="from">A node that is higher in hierarchy.</param> /// <param name="to">A node that is lower in hierarchy.</param> /// <returns>True if connection succeed. Otherwise false.</returns> public bool ConnectNodes(AFlowNode from, ANode to) { if (_nodes.Contains(from) && _nodes.Contains(to) && to != Root) { var n = to as AFlowNode; if (n != null) { //check nodes recursive to prevent circular trees if (IsConnected(from, n)) { return false; } } return from.AddNode(to); } return false; }
private bool IsConnected(AFlowNode from, AFlowNode to) { for (int i = 0; i < to.NodeCount; ++i) { var n = to.GetNode(i) as AFlowNode; if (n != null) { if (from == n || IsConnected(from, n)) { return(true); } } } return(false); }
/// <summary> /// Creates connection between one node to another. The connection is one one-way and tries to prevent circular to prevent infinity loops. /// </summary> /// <param name="from">A node that is higher in hierarchy.</param> /// <param name="to">A node that is lower in hierarchy.</param> /// <returns>True if connection succeed. Otherwise false.</returns> public bool ConnectNodes(AFlowNode from, ANode to) { if (_nodes.Contains(from) && _nodes.Contains(to) && to != Root) { var n = to as AFlowNode; if (n != null) { //check nodes recursive to prevent circular trees if (IsConnected(from, n)) { return(false); } } return(from.AddNode(to)); } return(false); }
private bool IsConnected(AFlowNode from, AFlowNode to) { for (int i = 0; i < to.NodeCount; ++i) { var n = to.GetNode(i) as AFlowNode; if (n != null) { if (from == n || IsConnected(from, n)) { return true; } } } return false; }
private void ConnectCallback(object obj) { var n = obj as AFlowNode; if (n != null) { _startConnection = n; } }
private void NodeLeftClicked(ANode node) { if (_tree == null || !_tree.Nodes.Contains(node)) { return; } Selection.activeObject = node; if(_startConnection != null) { if(_startConnection != node && _tree.ConnectNodes(_startConnection, node)) { AssetDatabase.SaveAssets(); } _startConnection = null; } }