void ImportTreeData() { for (int i = 0; i < BehaviourAsset.m_Datas.Length; i++) { BehaviourNodeGUI node = NewNode(BehaviourAsset.m_Datas[i]); if (node != null) { TreeGraph.AddNode(node); TreeCanvas.AddElement(node); } } int id = 0; FilterDelegate <PaintElement> filter = (x) => { BehaviourNodeGUI bx = x as BehaviourNodeGUI; return(bx != null && bx.Self.BTId == id); }; for (int i = 0; i < BehaviourAsset.m_Datas.Length; i++) { BTData data = BehaviourAsset.m_Datas[i]; id = data.m_Id; BehaviourNodeGUI gnode = TreeGraph.FindNode(filter) as BehaviourNodeGUI; if (gnode == null) { continue; } int len = data.m_Children == null ? 0 : data.m_Children.Length; for (int j = 0; j < len; j++) { id = data.m_Children[j]; BehaviourNodeGUI gchild = TreeGraph.FindNode(filter) as BehaviourNodeGUI; if (gchild != null) { TreeGraph.AddPath(0, gnode, gchild); } } } id = BehaviourAsset.m_RootNodeId; BehaviourNodeGUI root = TreeGraph.FindNode(filter) as BehaviourNodeGUI; if (root != null) { TreeGraph.AddPath(0, mRootGUI, root); } for (int i = 0; i < BehaviourAsset.m_Comments.Length; i++) { BehaviourCommentGUI comment = new BehaviourCommentGUI(this); comment.Comment = BehaviourAsset.m_Comments[i].m_Comment; comment.LocalRect = BehaviourAsset.m_Comments[i].m_Rect; CommentCanvas.AddElement(comment); } }
bool OnGraphKeyUp(KeyCode key) { if (IsPlaying) { return(false); } if (key == KeyCode.Delete) { List <BehaviourNodeGUI> nodes = new List <BehaviourNodeGUI>(); EditNodes((x) => { if (x.IsSelected) { nodes.Add(x); } }); for (int i = 0; i < nodes.Count; i++) { TreeCanvas.RemoveElement(nodes[i]); TreeGraph.RemoveNode(nodes[i]); } return(true); } if (key == KeyCode.C) { float w = Mathf.Abs(SelectionRect.GlobalRect.width); float dx = SelectionRect.GlobalRect.width < 0 ? -w : 0; float h = Mathf.Abs(SelectionRect.GlobalRect.height); float dy = SelectionRect.GlobalRect.height < 0 ? -h : 0; if (w > 40 && h > 30) { Rect rect = new Rect(SelectionRect.GlobalRect.xMin + dx, SelectionRect.GlobalRect.yMin + dy, w, h); BehaviourCommentGUI comment = new BehaviourCommentGUI(this); comment.LocalRect = CommentCanvas.CalculateLocalRect(rect); CommentCanvas.AddElement(comment); SelectNodes((x) => false); } } return(false); }