Ejemplo n.º 1
0
        //正在连线
        public void DrawConnectingLine()
        {
            if (mSelectedNode == null)
            {
                return;
            }
            Vector2 curPos = Event.current.mousePosition;             //MousePosToGraphPos(Event.current.mousePosition);

            if (mState == State.ConnectLeft)
            {
                BTDesignerUtility.DrawConnection(mSelectedNode.LeftPos, curPos);
            }
            if (mState == State.ConnectRight)
            {
                BTDesignerUtility.DrawConnection(mSelectedNode.RightPos, curPos);
            }
        }
Ejemplo n.º 2
0
        public void Draw()
        {
            foreach (NodeDesigner child in this.Children)
            {
                //先画子节点,让线条在最低层
                BTDesignerUtility.DrawConnection(this.RightPos, child.LeftPos);
                child.Draw();
            }

            //左链接
            Texture2D tex  = mLeftConnectTex;
            Rect      rect = new Rect(Pos.x - Width / 2 - tex.width / 6, Pos.y - tex.height / 4, tex.width / 2, tex.height / 2);

            GUI.DrawTexture(rect, tex);
            //右链接
            if (NodeData.Proto.child_limit > 0)
            {
                tex  = mRightConnectTex;
                rect = new Rect(Pos.x + Width / 2 - tex.width / 6 * 2, Pos.y - tex.height / 4.1f, tex.width / 2, tex.height / 2);
                GUI.DrawTexture(rect, tex);

                if (NodeData.Children.Count > 0)
                {
                    if (DesignerData.fold)
                    {
                        GUI.Label(new Rect(Pos.x + Width / 2 - 5f, Pos.y - 9f, tex.width, tex.height), "+");
                    }
                    else
                    {
                        GUI.Label(new Rect(Pos.x + Width / 2 - 8f, Pos.y - 9f, tex.width, tex.height), "—");
                    }
                }
            }

            rect = new Rect(Pos.x - Width / 2, Pos.y - Height / 2, Width, Height);
            GUI.DrawTexture(rect, mBoxTex);
            if (isSelected)
            {
                GUI.DrawTexture(rect, mBoxSelectHighLight);
            }
            else if (BTEditor.Instance.IsHighLight(this.NodeData))
            {
                GUI.DrawTexture(rect, mBoxHighLight);
            }

            GUIStyle style = new GUIStyle();

            style.normal.background = null;
            style.normal.textColor  = new Color(1, 1, 1);
            style.fontSize          = 15;
            if (!this.isSelected)
            {
                style.clipping = TextClipping.Clip;
            }
            GUI.Label(new Rect(Pos.x - Width / 2 + 5f, Pos.y - Height / 3, Width - 10f, Height / 2), NodeData.Proto.name, style);

            style.normal.textColor = new Color(0.8f, 0.8f, 0.8f);
            style.fontSize         = 12;
            style.wordWrap         = true;
            string deprecatedDesc = NodeData.Proto.isDeprecated? $"({NodeData.Proto.deprecatedDesc})" : "";

            GUI.Label(new Rect(Pos.x - Width / 2 + 6f, Pos.y, Width - 12f, Height / 2.1f), NodeData.Desc + deprecatedDesc, style);

            tex = null;
            switch (NodeData.NodeDeubgState)
            {
            case DebugState.True:
                tex = BTDesignerUtility.GetTexture("Execute");
                break;
                //                 case DebugState.False:
                //                     tex = BTDesignerUtility.GetTexture("False");
                //                     break;
                //                 case DebugState.Error:
                //                     tex = BTDesignerUtility.GetTexture("Error");
                //                     break;
            }
            if (tex != null)
            {
                GUI.DrawTexture(rect, tex);
                //                 string time = System.DateTime.Now.ToString();
                //                 GUI.Label(new Rect(Pos.x + Width / 2, Pos.y -20, Width - 12f, Height / 2.1f), time, style);
            }
        }