void UpdateTreeGraph() { mCopyDo = null; AddHistory(mAssetBinder.source); mBindStack.Clear(); mUndoStack.Clear(); AIGraph.ClearElements(); mContextNode = null; RaycastNode = null; RequestChild(null); if (Application.isPlaying) { var bind = mAssetBinder.RuntimeBinder; while (bind != null) { mBindStack.Insert(0, bind); bind = bind.Parent; } } AIGraph.AddElement(RootNode); if (mAssetBinder.targetTree != null) { List <BTNode> datas = new List <BTNode>(); mAssetBinder.targetTree.GetAllNodes(datas); foreach (var t in datas) { if (t.Asset == null) { mAssetBinder.targetTree.EditorDeleteNode(t); continue; } if (t.Asset is BTNodeAsset) { var node = new BTNodeGUI(this, t); AIGraph.AddElement(node); } } } RootNode.Resize(); mWires.UpdateWires(); var runner = TargetRunner; BlackboardMonitor.Visible = runner != null && Application.isPlaying; BlackboardMonitor.Blackboard = runner == null ? null : runner.Blackboard; }
public override bool DoEditWithUndo() { if (isDo || SelectionCount == 0) { return(false); } var nodes = editor.TargetTree.EditorPaste(selection, deltaPosition); foreach (var t in nodes) { if (t.Asset is BTNodeAsset) { var newitem = new BTNodeGUI(editor, t); editor.AIGraph.AddElement(newitem); } } editor.AddDelayTask(BehaviourTreeEditor.ACT_UPDATE_WIRES, editor.Wires.UpdateWires); editor.SetSelections((x) => { return(GlobalUtil.FindIndex(nodes, (y) => y == x.GetNode()) != -1); }); return(false); }
public override bool DoEditWithUndo() { if (isDo) { return(false); } isDo = true; BTNode asset; switch (mod.CategoryId) { case AIModules.CATE_CONDITION: if (context == null || !(context.Asset is BTNodeAsset)) { //EditorUtility.DisplayDialog("Error", string.Format("此处无法添加 \"{0}\"。", mod.Title), "OK"); editor.Tip.Show(string.Format("!!!无法添加 \"{0}\"。", mod.Title), 5); return(false); } else { asset = editor.TargetTree.EditorCreateNode(mod.ModuleType, position); ((BTNodeAsset)context.Asset).EditorConditionIds.Add(asset.Identify); editor.EditNodes((x) => { if (x.GetNode() == context) { x.Resize(); } }); newNode = asset; editor.RequestChild(null); return(true); } case AIModules.CATE_COMPOSITE: case AIModules.CATE_TASK: if (editor.PresentParentRequest != null && !mod.IsController) { editor.Tip.Show(string.Format("!!!无法添加\"{0}\"", mod.Title), 5); return(false); } asset = editor.TargetTree.EditorCreateNode(mod.ModuleType, position); if (asset.Asset is BTNodeAsset) { var node = new BTNodeGUI(editor, asset); editor.AIGraph.AddElement(node); } if (editor.PresentChildRequest == editor.RootNode) { editor.TargetTree.m_RootId = asset.Identify; } else if (editor.PresentChildRequest != null && editor.PresentChildRequest.GetNode() != null) { var parent = editor.PresentChildRequest.GetNode(); editor.TargetTree.EditorResetParent(asset.Identify, parent.Identify); } else if (editor.PresentParentRequest != null && editor.PresentParentRequest.GetNode() != null) { var child = editor.PresentParentRequest.GetNode(); editor.TargetTree.EditorResetParent(child.Identify, asset.Identify); } newNode = asset; editor.AddDelayTask(BehaviourTreeEditor.ACT_UPDATE_WIRES, editor.Wires.UpdateWires); editor.RequestChild(null); editor.SetSelections((x) => x.GetNode() == asset); return(true); case AIModules.CATE_SERVICE: if (editor.TargetTree.EditorContainsNodeType(mod.ModuleType)) { editor.Tip.Show("已经存在该服务", 5); return(false); } asset = editor.TargetTree.EditorCreateNode(mod.ModuleType, position); editor.RootNode.Resize(); return(true); default: return(false); } }