void DrawConnectDots(Rect dotRect) { Vector2 offset = Vector2.zero; if (TreeNode.IsParentNode()) { var asParent = TreeNode.AsParentNode(); var nodeCount = asParent.GetChildNodes().Count; if (nodeCount > 0) { if (asParent.HasChildrenSlots()) { offset.x -= ConnectorSize.x * nodeCount * 0.5f; } for (int i = 0; i < nodeCount; i++) { GUI.Box( new Rect(dotRect.center.x - ConnectorSize.x * 0.5f + offset.x, dotRect.yMax - ConnectorSize.y * 0.25f, ConnectorSize.x, ConnectorSize.y), new GUIContent(), SpaceEditorStyles.DotFlowTarget ); if (BehaviourTreeEditor.GetInstance().ExecuteInRuntime()) { GUI.color = CurrentColor; } GUI.Box( new Rect(dotRect.center.x - ConnectorSize.x * 0.5f + offset.x, dotRect.yMax - ConnectorSize.y * 0.25f, ConnectorSize.x, ConnectorSize.y), new GUIContent(), SpaceEditorStyles.DotFlowTargetFill ); GUI.color = Color.white; offset.x += ConnectorSize.x; } } if (asParent.HasChildrenSlots()) { Vector2 pos = offset + new Vector2(dotRect.center.x - ConnectorSize.x * 0.5f, dotRect.yMax - ConnectorSize.y * 0.25f); Rect rect = new Rect(pos.x, pos.y, ConnectorSize.x, ConnectorSize.y); if (rect.Contains(Event.current.mousePosition)) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (OnNewChildNode != null) { OnNewChildNode(this, rect.center); Event.current.Use(); } } } GUI.Box(rect, GUIContent.none, SpaceEditorStyles.DotFlowTarget); } } }
public override Color GetParentConnectColor(GraphNode childNode) { if (BehaviourTreeEditor.GetInstance().ExecuteInRuntime()) { return(CurrentColor); } return(Color.white); }
void SetColor() { TargetColor = GetColor(); if (BehaviourTreeEditor.GetInstance().ExecuteInRuntime()) { CurrentColor = Color.Lerp(CurrentColor, TargetColor, Time.deltaTime); } else { CurrentColor = TargetColor; } GUI.color = CurrentColor; }
void DrawParentDot(Rect dotRect) { if (TreeNode && TreeNode.Parent) { GUI.Box( new Rect(dotRect.center.x - ConnectorSize.x * 0.5f, dotRect.yMin - ConnectorSize.y * 0.5f, ConnectorSize.x, ConnectorSize.y), GUIContent.none, SpaceEditorStyles.DotFlowTarget ); if (BehaviourTreeEditor.GetInstance().ExecuteInRuntime()) { GUI.color = CurrentColor; } GUI.Box( new Rect(dotRect.center.x - ConnectorSize.x * 0.5f, dotRect.yMin - ConnectorSize.y * 0.5f, ConnectorSize.x, ConnectorSize.y), GUIContent.none, SpaceEditorStyles.DotFlowTargetFill ); GUI.color = Color.white; } }
Color GetColor() { if (BehaviourTreeEditor.GetInstance() != null && BehaviourTreeEditor.GetInstance().ExecuteInRuntime()) { switch (BehaviourTreeEditor.GetInstance().CheckNodeStatus(TreeNode)) { case NodeResult.Suspended: return(Color.gray); case NodeResult.Success: return(Color.green); case NodeResult.Failrue: return(Color.red); case NodeResult.Running: return(Color.yellow); default: return(Color.clear); } } else if (TreeNode.IsRootNode()) { return(Color.blue + Color.grey); } else if (TreeNode.IsParentNode()) { return(Color.cyan + Color.grey); } else { return(Color.white); } }