void OnGUI_OneBlock()
        {
            GUINode node  = this;
            var     style = new GUIStyle(node.isSelected ? BTLSyntaxHighlight.style_selected : BTLSyntaxHighlight.style_running);
            //GUIStyle style = new GUIStyle();

            bool displayInsert = false;

            if (!node.isSelected && (GUIBTScript.mode == GUIBTScript.Mode.MouseDrag || GUIBTScript.mode == GUIBTScript.Mode.InsertingNewNode))
            {
                switch (node.mouseHoverPosition)
                {
                case MouseHoverPosition.Above: style = BTLSyntaxHighlight.style_insert_above; break;

                case MouseHoverPosition.Below: style = BTLSyntaxHighlight.style_insert_below; break;

                case MouseHoverPosition.Center: style = BTLSyntaxHighlight.style_insert_in; break;
                }
                displayInsert = true;
            }

            var sbLabel = new System.Text.StringBuilder();

            if (displayInsert && mouseHoverPosition == MouseHoverPosition.Left)
            {
                sbLabel.Append("|");
                //GUILayout.Label(BTLSyntaxHighlight.texture_insert_LeftRigth, GUILayout.ExpandWidth(false));
            }

            sbLabel.Append(node.label);


            bool withParenthesis = parameters.Count > 0 && nodeType != NodeType.Comment;

            if (withParenthesis)
            {
                sbLabel.Append("(");
            }

            for (int i = 0; i < node.parameters.Count; i++)
            {
                var p = node.parameters[i];
                if (nodeType == NodeType.Comment && p.value.Trim() == "")
                {
                    sbLabel.Append("...");
                }
                else
                {
                    sbLabel.Append(p.value);

                    if (withParenthesis && i + 1 < node.parameters.Count)
                    {
                        sbLabel.Append(", ");
                    }
                }
            }

            if (withParenthesis)
            {
                sbLabel.Append(")");
            }


            if (displayInsert && mouseHoverPosition == MouseHoverPosition.Right)
            {
                sbLabel.Append("|");
                //GUILayout.Label(BTLSyntaxHighlight.texture_insert_LeftRigth, GUILayout.ExpandWidth(false));
            }

            GUI.SetNextControlName(node.controlName);
            if (node.nodeType == NodeType.EmptyLine)
            {
                GUILayout.Label(node.label, style, GUILayout.ExpandWidth(true));
            }
            else
            {
                GUILayout.Label(sbLabel.ToString(), style);
            }


            // Selection and drag start
            if (isMouseOver && Event.current.isMouse && Event.current.type == EventType.MouseDown)
            {
                if (GUIBTScript.isCTRLPressed)
                {
                    if (this.isSelected)
                    {
                        GUIBTScript.SelectionRemove(node);
                    }
                    else
                    {
                        GUIBTScript.SelectionAdd(node);
                    }
                }
                else
                {
                    if (!isSelected)
                    {
                        GUIBTScript.SelectionClear();
                    }
                    GUIBTScript.SelectionAdd(node);
                }

                GUI.FocusControl(node.controlName);
            }

            if (isMouseOver && Event.current.isMouse && Event.current.type == EventType.MouseUp && !GUIBTScript.isCTRLPressed && !GUIBTScript.isControlLocked)
            {
                GUIBTScript.SelectionClear();
                GUIBTScript.SelectionAdd(node);
                GUI.FocusControl(node.controlName);
            }
        }
        public void OnGUI()
        {
            var node = this;

            GUINode._current = this;

            // Recompute rects when edit state has changed.
            if (GUIBTScript.isEventSafe)
            {
                if (isEdited == false && _isEditedPrev)
                {
                    SetDirty();
                }

                if (isEdited && _isEditedPrev == false)
                {
                    GUIBTScript.SelectionClear();
                }

                _isEditedPrev = isEdited;
            }

            if (node.nodeType == NodeType.TaskList)
            {
                OnGUI_TaskListSelector();
            }
            else
            {
                if ((node.isSelected || node == GUIBTScript.cursorNode) && !isRectDirty && !isEdited)
                {
                    OnGUI_OneBlock();
                }
                else
                {
                    OnGUI_ColoredNode();
                }
            }

            // Edit parameter when left mouse click.
            bool isClicked = Event.current.isMouse && Event.current.type == EventType.MouseDown && Event.current.button == 0;
            var  mpos      = Event.current.mousePosition;

            if (!isRectDirty && !GUIBTScript.isCTRLPressed && isClicked && GUIBTScript.mode == GUIBTScript.Mode.Normal)
            {
                bool isParameterClicked = false;
                for (int i = 0; i < parameters.Count; i++)
                {
                    var r            = parameterRects[i];
                    var isWithinRect = r.Contains(mpos);
                    parameters[i].isEdited = isWithinRect;

                    if (isWithinRect)
                    {
                        isParameterClicked = true;
                    }
                }

                if (this.rect.Contains(mpos) && !isParameterClicked)
                {
                    bool isDoubleClicked = Time.realtimeSinceStartup - lastClickTime < 0.4f;
                    lastClickTime = Time.realtimeSinceStartup;
                    if (isDoubleClicked && this.nodeType == NodeType.Task && this.label.ToLower() != "tree")
                    {
                        GUIBTScript.OpenScript(this);
                    }
                }
            }

            // On press Enter or Esc stop editing the parameter.
            if (Event.current.isKey && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Escape))
            {
                foreach (var p in parameters)
                {
                    if (p.isEdited)
                    {
                        p.isEdited = false;
                    }
                }
            }

            // Locate mouse position in rect.
            if (Event.current.type == EventType.Repaint)
            {
                if (rect.Contains(mpos))
                {
                    isMouseOver = true;

                    if (GUIBTScript.cursorNode != node)
                    {
                        GUIBTScript.cursorNode = node;
                        //GUIBTScript.current.redraw = true;
                    }

                    float f  = 0.3f;
                    var   w  = rect.width;
                    var   wb = w * f;
                    var   h  = rect.height;
                    var   hb = h * f;

                    if (mpos.y < rect.y + hb)
                    {
                        mouseHoverPosition = MouseHoverPosition.Above;
                    }
                    else
                    if (mpos.y > rect.y + h - hb && node.line.children.Count == 0)
                    {
                        mouseHoverPosition = MouseHoverPosition.Below;
                    }
                    else
                    if (mpos.x < rect.x + wb)
                    {
                        mouseHoverPosition = MouseHoverPosition.Left;
                    }
                    else
                    if (mpos.x > rect.x + w - wb)
                    {
                        mouseHoverPosition = MouseHoverPosition.Right;
                    }
                    else
                    if (nodeType == NodeType.Structural && node.line.nodes[0] == node)
                    {
                        mouseHoverPosition = MouseHoverPosition.Center;
                    }
                }
                else
                {
                    isMouseOver = false;
                }
            }
            else if (node != GUIBTScript.cursorNode)
            {
                mouseHoverPosition = MouseHoverPosition.None;
            }
        }