示例#1
0
        private void DrawHeader()
        {
            Rect titlePosition = GUILayoutUtility.GetRect(GUIContent.none, BTEditorStyle.RegionBackground, GUILayout.ExpandWidth(true), GUILayout.Height(15.0f));

            titlePosition.x     -= 19;
            titlePosition.y     -= 2;
            titlePosition.width += 28;

            Rect optionsButtonPosition = new Rect(titlePosition.xMax - 28.0f, titlePosition.y, 20.0f, 20.0f);

            DrawCategoryHeader(titlePosition, m_target.Title);
            if (GUI.Button(optionsButtonPosition, BTEditorStyle.OptionsIcon, EditorStyles.label))
            {
                GenericMenu menu = BTContextMenuFactory.CreateNodeInspectorContextMenu(m_target);
                menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
            }

            GUILayout.Space(2.5f);
            DrawSeparator();

            m_target.Name = EditorGUILayout.TextField("Name", m_target.Name);
            EditorGUILayout.LabelField("Comment");
            m_target.Comment = EditorGUILayout.TextArea(m_target.Comment, BTEditorStyle.MultilineTextArea);

            if (m_graphNode.Parent != null && m_graphNode.Parent.Node is WeightedRandom)
            {
                EditorGUILayout.Space();
                m_target.Weight = EditorGUILayout.Slider("Weight", m_target.Weight, 0.0f, 1.0f);
            }

            EditorGUILayout.Space();
        }
示例#2
0
        private void DrawServices()
        {
            EditorGUILayout.Space();
            DrawSeparator();

            for (int i = 0; i < m_target.Services.Count; i++)
            {
                Service service          = m_target.Services[i];
                Rect    headerPos        = GUILayoutUtility.GetRect(0, 18.0f, GUILayout.ExpandWidth(true));
                Rect    foldoutPos       = new Rect(headerPos.x, headerPos.y, 20.0f, headerPos.height);
                Rect    labelPos         = new Rect(foldoutPos.xMax, headerPos.y, headerPos.width - 38.0f, headerPos.height);
                Rect    optionsButtonPos = new Rect(labelPos.xMax, headerPos.y, 18.0f, headerPos.height);

                service.IsExpanded = EditorGUI.Foldout(foldoutPos, service.IsExpanded, GUIContent.none);
                EditorGUI.LabelField(labelPos, service.Title, BTEditorStyle.BoldLabel);
                if (GUI.Button(optionsButtonPos, BTEditorStyle.OptionsIcon, EditorStyles.label))
                {
                    GenericMenu menu = BTContextMenuFactory.CreateServiceContextMenu(m_target, i);
                    menu.DropDown(new Rect(BTEditorCanvas.Current.Event.mousePosition, Vector2.zero));
                }

                if (service.IsExpanded)
                {
                    var serviceInspector = GetServiceInspector(service);
                    serviceInspector.OnInspectorGUI();
                }

                DrawSeparator();
            }
        }
示例#3
0
        /// <summary>
        /// 绘制节点的Inspector上面的约束
        /// </summary>
        private void DrawConstraints()
        {
            EditorGUILayout.Space();
            DrawSeparator();

            for (int i = 0; i < m_target.Constraints.Count; i++)
            {
                Constraint constraint       = m_target.Constraints[i];
                Rect       headerPos        = GUILayoutUtility.GetRect(0, 18.0f, GUILayout.ExpandWidth(true));
                Rect       foldoutPos       = new Rect(headerPos.x, headerPos.y, 20.0f, headerPos.height);
                Rect       labelPos         = new Rect(foldoutPos.xMax, headerPos.y, headerPos.width - 56.0f, headerPos.height);
                Rect       togglePos        = new Rect(labelPos.xMax, headerPos.y, 18.0f, headerPos.height);
                Rect       optionsButtonPos = new Rect(togglePos.xMax, headerPos.y, 18.0f, headerPos.height);

                constraint.IsExpanded = EditorGUI.Foldout(foldoutPos, constraint.IsExpanded, GUIContent.none);
                EditorGUI.LabelField(labelPos, constraint.Title, BTEditorStyle.BoldLabel);
                // 控制属性反转
                constraint.InvertResult = EditorGUI.Toggle(togglePos, GUIContent.none, constraint.InvertResult);
                if (GUI.Button(optionsButtonPos, BTEditorStyle.OptionsIcon, EditorStyles.label))
                {
                    GenericMenu menu = BTContextMenuFactory.CreateConstraintContextMenu(m_target, i);
                    menu.DropDown(new Rect(BTEditorCanvas.Current.Event.mousePosition, Vector2.zero));
                }

                if (constraint.IsExpanded)
                {
                    var constraintInspector = GetConstraintInspector(constraint);
                    constraintInspector.OnInspectorGUI();
                }

                DrawSeparator();
            }
        }
 private void DrawOptions(Rect screenRect)
 {
     if (GUI.Button(screenRect, BTEditorStyle.OptionsIcon, EditorStyles.toolbarButton))
     {
         GenericMenu menu = BTContextMenuFactory.CreateBehaviourTreeEditorMenu(this);
         menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
     }
 }
示例#5
0
        private void HandleEvents(Rect screenRect)
        {
            if (BTEditorCanvas.Current.Event.type == EventType.MouseDown && BTEditorCanvas.Current.Event.button == SELECT_MOUSE_BUTTON)
            {
                if (screenRect.Contains(BTEditorCanvas.Current.Event.mousePosition))
                {
                    ClearSelection();

                    m_canBeginBoxSelection = true;
                    m_selectionBoxStartPos = BTEditorCanvas.Current.Event.mousePosition;
                    BTEditorCanvas.Current.Event.Use();
                }
            }
            else if (BTEditorCanvas.Current.Event.type == EventType.MouseDrag && BTEditorCanvas.Current.Event.button == SELECT_MOUSE_BUTTON)
            {
                if (screenRect.Contains(BTEditorCanvas.Current.Event.mousePosition))
                {
                    if (!m_drawSelectionBox && m_canBeginBoxSelection)
                    {
                        m_drawSelectionBox = true;
                    }

                    BTEditorCanvas.Current.Event.Use();
                }
            }
            else if (BTEditorCanvas.Current.Event.type == EventType.MouseUp)
            {
                if (screenRect.Contains(BTEditorCanvas.Current.Event.mousePosition))
                {
                    if (BTEditorCanvas.Current.Event.button == SELECT_MOUSE_BUTTON)
                    {
                        if (m_drawSelectionBox)
                        {
                            m_drawSelectionBox = false;
                        }

                        BTEditorCanvas.Current.Event.Use();
                    }
                    else if (BTEditorCanvas.Current.Event.button == CONTEXT_MOUSE_BUTTON)
                    {
                        GenericMenu menu = BTContextMenuFactory.CreateGraphContextMenu(this);
                        menu.DropDown(new Rect(BTEditorCanvas.Current.Event.mousePosition, Vector2.zero));

                        BTEditorCanvas.Current.Event.Use();
                    }
                }

                m_canBeginBoxSelection = false;
            }
        }
示例#6
0
        private void ShowContextMenu()
        {
            GenericMenu menu = BTContextMenuFactory.CreateNodeContextMenu(this);

            menu.DropDown(new Rect(BTEditorCanvas.Current.Event.mousePosition, Vector2.zero));
        }