Ejemplo n.º 1
0
        public void Init()
        {
            NodeData.Proto = BehaviorManager.GetInstance().GetNodeTypeProto(NodeData.name);
            string[] arr = NodeData.Proto.style.Split('/');
            if (arr.Length > 1 && arr[1] == "value")
            {
                mShowValue = true;
            }
            string style = arr.Length > 0? arr[0] : "";

            if (style == "")
            {
                switch (NodeData.Classify)
                {
                case "装饰节点":
                    style = "green";
                    break;

                case "复合节点":
                    style = "blue";
                    break;

                case "条件节点":
                    style = "orange";
                    break;
                }
                switch (NodeData.name)
                {
                case "Sequence":
                    style = "blue";
                    break;

                case "Selector":
                    style = "green";
                    break;

                default:
                    style = "default";
                    break;
                }
            }
            mBoxTex             = BehaviorDesignerUtility.GetTexture(style);
            mBoxHighLight       = BehaviorDesignerUtility.GetTexture("HighLight");
            mBoxSelectHighLight = BehaviorDesignerUtility.GetTexture("SelectHighLight");

            if (mBoxTex == null)
            {
                mBoxTex = BehaviorDesignerUtility.GetTexture("default");
            }
            if (mBoxTex == null)
            {
                Log.Info("mBoxTex null " + NodeData.nodeId);
            }
            Width  = mBoxTex.width / 2;
            Height = mBoxTex.height / 2;

            mLeftConnectTex  = BehaviorDesignerUtility.GetTexture("LeftConnect");
            mRightConnectTex = BehaviorDesignerUtility.GetTexture("RightConnect");
        }
Ejemplo n.º 2
0
        //正在连线
        public void DrawConnectingLine()
        {
            if (mSelectedNode == null)
            {
                return;
            }
            var curPos = Event.current.mousePosition;             //MousePosToGraphPos(Event.current.mousePosition);

            if (mState == State.ConnectLeft)
            {
                BehaviorDesignerUtility.DrawConnection(mSelectedNode.LeftPos, curPos);
            }
            if (mState == State.ConnectRight)
            {
                BehaviorDesignerUtility.DrawConnection(mSelectedNode.RightPos, curPos);
            }
        }
Ejemplo n.º 3
0
        public void DrawBackground()
        {
            float width = 15f;
            var   bgTex = BehaviorDesignerUtility.GetTexture("Bg");

            GUI.DrawTexture(new Rect(0, 0, mGraphRect.width, mGraphRect.height), bgTex);

            var lineTex = BehaviorDesignerUtility.GetTexture("BgLine");

            for (int i = 0; i < mGraphRect.width / width; i++)
            {
                GUI.DrawTexture(new Rect(width * i, 0, 1f, mGraphRect.height), lineTex);
            }
            for (int j = 0; j < mGraphRect.height / width; j++)
            {
                GUI.DrawTexture(new Rect(0, width * j, mGraphRect.width, 1f), lineTex);
            }
        }
        public GUIStyle GetButtonStyle()
        {
            GUIStyle style = new GUIStyle();

            style.fontSize  = 15;
            style.alignment = TextAnchor.MiddleLeft;
            GUIStyleState onHoverStyleState = new GUIStyleState();

            onHoverStyleState.textColor  = textHighLightColor;
            onHoverStyleState.background = BehaviorDesignerUtility.GetTexture("blue");
            style.hover = onHoverStyleState;

            GUIStyleState onNormalStyleState = new GUIStyleState();

            onNormalStyleState.textColor = textColor;
            style.normal = onNormalStyleState;
            return(style);
        }
Ejemplo n.º 5
0
 public void DrawMouseIcon(string resName)
 {
     GUI.DrawTexture(new Rect(Event.current.mousePosition.x - 10, Event.current.mousePosition.y - 20, 17, 20),
                     BehaviorDesignerUtility.GetTexture(resName));
 }
Ejemplo n.º 6
0
        public void Draw()
        {
            foreach (var child in this.Children)
            {
                //先画子节点,让线条在最低层
                BehaviorDesignerUtility.DrawConnection(this.RightPos, child.LeftPos);
                child.Draw();
            }

            //左链接
            var tex  = mLeftConnectTex;
            var 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 (BehaviorManager.GetInstance().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.describe + deprecatedDesc, style);

            tex = null;
            switch (NodeData.NodeDeubgState)
            {
            case DebugState.True:
                tex = BehaviorDesignerUtility.GetTexture("Execute");
                break;
                //                 case DebugState.False:
                //                     tex = BehaviorDesignerUtility.GetTexture("False");
                //                     break;
                //                 case DebugState.Error:
                //                     tex = BehaviorDesignerUtility.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);
            }
        }