public void ShowContext(BehaviourNodeGUI context) { if (EditorApplication.isPlaying || context == null) { return; } List <BehaviourMeta> lst; if (mDecoratorList.Count < 2 || !BehaviourModuleManager.GetOrNewInstance().Decorators.Contains(mDecoratorList[1].BTMeta)) { mMinDecoratorWidth = 200; mDecoratorList.Clear(); lst = BehaviourModuleManager.GetOrNewInstance().Decorators; string category = null; for (int i = 0; i < lst.Count; i++) { MetaUI m = new MetaUI(lst[i]); if (m.BTMeta.Category != category) { category = m.BTMeta.Category; mDropDownMeta = new MetaUI(category); mDecoratorList.Add(mDropDownMeta); } mDecoratorList.Add(m); mMinDecoratorWidth = Mathf.Max(mMinDecoratorWidth, m.Width); } } Mode = EMode.alter_node; Visible = true; Context = context; Rect rect = new Rect(); rect.size = new Vector2(mMinDecoratorWidth + mMinTaskWidth, 270); Vector2 gsize = rect.size * GlobalScale; Vector2 delta = Vector2.zero; if (mWindow.GlobalMousePosition.y + gsize.y > mWindow.RootCanvas.GlobalRect.height) { delta.y = -rect.size.y; } if (mWindow.GlobalMousePosition.x + gsize.x > mWindow.RootCanvas.GlobalRect.width) { delta.x = -rect.size.x; } rect.position = Parent.CalculateLocalPosition(mWindow.GlobalMousePosition) + delta; LocalRect = rect; mWindow.SelectNodes((x) => x == context); mDragEnd = true; }
public override bool InteractMouseClick(EMouseButton button, Vector2 mousePositoin) { if (mWindow.IsPlaying && RuntimeNode != null) { RuntimeNode.BreakToggle = !RuntimeNode.BreakToggle; return(true); } if (mUseEvents) { mUseEvents = false; } else if (button == EMouseButton.right) { mWindow.BeginEditNode(null, BehaviourTreeDesignerWindow.ENodeEditMode.none); mWindow.ContextMenu.ShowContext(this); } else if (mWindow.ContextMenu.Visible) { mWindow.ContextMenu.Hide(); return(true); } else if (mRaycastDecorator != null && mRaycastDecorator.BTMeta.NodeType == EBTNodeType.condition) { mRaycastDecorator.NotFlag = !mRaycastDecorator.NotFlag; } else if (Event.current.control) { mWindow.SelectNodes((x) => x.IsSelected || x == this); } else { mWindow.SelectNodes((x) => x == this); } mWindow.SelectComment(null, false); return(true); }
public override bool InteractMouseClick(EMouseButton button, Vector2 mousePosition) { if (button == EMouseButton.left && mWindow.EditMode == BehaviourTreeDesignerWindow.ENodeEditMode.none) { if (IsSelected) { mEditMode = true; } else { mWindow.SelectComment(this, Event.current.control); } mWindow.SelectNodes((x) => false); mWindow.ContextMenu.Hide(); return(true); } return(false); }