Esempio n. 1
0
        public override void DrawMenu()
        {
            base.DrawMenu();
            GUI.DrawTexture(m_CurShowArea, EditorImageHelper.GetImageByPath(m_BgImagePath)); //背景

            ToolBarGroup_Signal_Menu.DrawToolBarGroup();
        }
        public override void DrawMenu()
        {
            base.DrawMenu();
            Rect MenuShowArea = new Rect(0, 0, Constants.NodeParametersWindowWidth, Screen.height - Constants.ToolBarHeight);  //菜单显示的区域 去除了工具栏的位置

            #region 绘制菜单显示区域的背景
            Color cor = GUI.color;
            GUI.color = Color.gray;  //更改当前绘制GUI的颜色
            GUI.DrawTexture(MenuShowArea, EditorImageHelper.GetImageByPath(m_NodeBgPath));
            GUI.color = cor;
            #endregion

            GUILayout.BeginVertical();
            #region 工具栏 也可以使用自己定义的工具栏
            SelectedToolIndex = GUILayout.Toolbar(SelectedToolIndex, m_Tools.ToArray(), GUILayout.Width(Constants.NodeParametersWindowWidth),
                                                  GUILayout.Height(Constants.ToolBarHeight));    //绘制工具栏
            #endregion

            #region 左侧的 窗口显示的内容  属性结构/节点属性/......
            GUILayout.BeginArea(new Rect(MenuShowArea.x, MenuShowArea.y + Constants.ToolBarHeight, MenuShowArea.width, MenuShowArea.height));
            //Debug.Log(">>>>> " + (Screen.height - Constants.ToolBarHeight));
            ShowSubMenuBySelectTool();
            GUILayout.EndArea();
            #endregion

            GUILayout.EndVertical();
        }
Esempio n. 3
0
        protected bool DrawInOutPutLinePoint(NodeParent.NodeFileInfor fieldInfor, NodeParent belongNode, float sartPosY, System.Action <FieldInfo> onClickLineNode)
        {
            if (fieldInfor.m_NodeAttribute.InOut == NodeInOutEnum.None)
            {
                return(false);
            }
            NodeParent.NodeLineInfor lineInfor = belongNode.GetNodeLineInforOfField(fieldInfor.m_FieldInfo);
            if (lineInfor == null)
            {
                return(false);
            }
            Rect rect = new Rect(0, sartPosY, Constants.NodeLinePointSize.x, Constants.NodeLinePointSize.y);

            //**记录当前线点在节点编辑区域的坐标
            lineInfor.m_Pos = belongNode.NodeSpace2EditorWinSpace(belongNode.NodeFieldItem2NodeSpace(new Vector2(rect.x, rect.y)));      //BehaciorEditor Win 坐标系下坐标

            belongNode.RecordLinePoint(fieldInfor.m_FieldInfo, new Rect(lineInfor.m_Pos.x, lineInfor.m_Pos.y, rect.width, rect.height)); //记录

            if (lineInfor.m_ConnectNodeLine.Count == 0)
            {
                GUI.DrawTexture(rect, EditorImageHelper.GetImageByPath(m_NotConnectLinePath));

                //if (GUI.Button(rect, new GUIContent("", NoConnectImg)))
                //{
                //    if (onClickLineNode != null)
                //        onClickLineNode(fieldInfor.m_FieldInfo);
                //}

                //if(  GUILayout.Button(new GUIContent("", NoConnectImg), GUILayout.Width(Constants.NodeLinePointSize.x), GUILayout.Height(Constants.NodeLinePointSize.y)))
                //  {
                //      if (onClickLineNode != null)
                //          onClickLineNode(fieldInfor.m_FieldInfo);
                //  }
                // // GUI.DrawTexture(new Rect(0, 0, Constants.NodeLinePointSize.x, Constants.NodeLinePointSize.y), NoConnectImg);
            }
            else
            {
                GUI.DrawTexture(rect, EditorImageHelper.GetImageByPath(m_ConnectingLinePath));

                //if (GUILayout.Button(new GUIContent("", ConnectedImg), GUILayout.Width(Constants.NodeLinePointSize.x), GUILayout.Height(Constants.NodeLinePointSize.y)))
                //{
                //    if (onClickLineNode != null)
                //        onClickLineNode(fieldInfor.m_FieldInfo);
                //}
                //   GUI.DrawTexture(new Rect(0, 0, Constants.NodeLinePointSize.x, Constants.NodeLinePointSize.y), ConnectedImg);
            }
            return(true);
        }
        private void OnGUI()
        {
            if (NeedRepaint)
            {
                NeedRepaint = false;
                Repaint();
            }

            m_MouseDetail           = Event.current.mousePosition - m_PreviousMousePosition;
            m_PreviousMousePosition = CurMousePosition;

            #region 整体布局

            #region 绘制背景
            float scale = 1f;  //通过scale控制缩放
            // GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), m_MenuBg);  //背景
            //Debug.Log("position =" + position);
            //指定要显示在的屏幕区域
            Rect showArea = new Rect(0, 0, Screen.width, Screen.height);
            //指定要显示的图片区域 ***由于Unity UV与Unity坐标轴不一样
            Texture editorBgImg = EditorImageHelper.GetImageByPath(m_NodeEditorBgPath);

            Rect sourceRect = new Rect(0, -Screen.height / editorBgImg.height, scale * Screen.width / editorBgImg.width, scale * Screen.height / editorBgImg.height);
            GUI.DrawTextureWithTexCoords(showArea, editorBgImg, sourceRect); //根据纹理绘制一张贴图  这里纹理的WrapMode=Repeat;
            #endregion

            #region 绘制 左右两个窗口
            GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
            GUILayout.BeginHorizontal();
            NodeParametersWindow_Menu.DrawMenu(); //节点信息区
            m_BehaviorTreeEditorMenu.DrawMenu();  //编辑区
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            #endregion

            #endregion

            CurMousePosition = Event.current.mousePosition; //光标相对于当前窗口的位置
            // Debug.Log("m_MousePosition=" + CurMousePosition);
            HandleEvent();                                  //处理GUI事件
        }
Esempio n. 5
0
        /// <summary>
        /// 绘制当前节点
        /// </summary>
        public virtual void DrawNode(EditorRecordNode recordNode)
        {
            if (m_IsInitialed == false)
            {
                m_IsInitialed = true;
                //Debug.Log("DrawNode >>>  Initial");
                GetAllNodeField(recordNode.m_ActionScript);
            }
            Rect rect = new Rect(m_Pos.x, m_Pos.y, GetNodeWidth(), GetNodeHeight());

            //  Debug.Log("DrawNode rectrect= " + rect);
            GUI.DrawTexture(rect, EditorImageHelper.GetImageByPath(m_NodeBgImg));
            //Debug.Log("xxx zz  " + m_NodeBaseWidth * m_NodeWidthScale);
            GUILayout.BeginArea(rect);
            GUILayout.BeginVertical();
            #region Title
            GUILayout.Label(new GUIContent(recordNode.m_ActionScript.m_BehaviorActionAttribute.ActionType.Name), Style.Label_Style_Title,
                            GUILayout.Width(GetNodeWidth() - Constants.NodeFieldOffsetBounder), GUILayout.Height(m_NodeTitleHeight));

            #endregion

            #region Node Field
            GUILayout.BeginArea(new Rect(0, m_NodeTitleHeight, rect.width, rect.height - m_NodeTitleHeight));
            float startPos = 0;
            foreach (var item in m_AllNodeFiled)
            {
                DrawNodeField(item, startPos);
                GUILayout.Space(Constants.NodeFileItemSpace);
                startPos += Constants.NodeFileItemSpace + GetNodeHeight(item.m_NodeAttribute) * Constants.NodeFieldItemHeight;
            }
            GUILayout.EndArea();
            #endregion

            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
Esempio n. 6
0
        public override void DrawMenu()
        {
            if (IsActive == false)
            {
                //Debug.Log("处于非激活状态" + m_MenuName);
                return;
            }
            base.DrawMenu();
            //    Debug.Log("DrawMenu  " + m_CurShowArea);

            GUILayout.BeginArea(m_CurShowArea);
            GUI.DrawTexture(new Rect(0, 0, m_CurShowArea.width, m_CurShowArea.height), EditorImageHelper.GetImageByPath(m_NodeBgPath));
            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition, false, true, GUILayout.Width(Constants.ContexNodeActionMenuSize.x),
                                                         GUILayout.Height(Constants.ContexNodeActionMenuSize.y));

            // Debug.Log("<<<<<<<< " + m_CurShowArea.height+ "     m_TopSpaceHeight="+ m_TopSpaceHeight);
            //***添加一个空白的标签以便于正确的识别树形结构的高度
            float treeViewHeight = NodeActionTreeView_View.ShowTreeView();

            GUILayout.Label("", GUILayout.Height(treeViewHeight));

            GUILayout.EndScrollView();
            GUILayout.EndArea();

            //Debug.Log("xxx" + Event.current.mousePosition);
        }