Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
 public void OnDestroy()
 {
     BehaviorManager.GetInstance().Clear();
 }