コード例 #1
0
        private void OnGUI()
        {
            if (m_btAsset != null)
            {
                // 顶部导航
                Rect navHistoryRect = new Rect(0.0f, 0.0f, position.width, 20.0f);
                // 顶部导航的设置按钮
                Rect optionsRect = new Rect(position.width - 20.0f, 0.0f, 20.0f, 20.0f);
                // 底部显示路径的位置
                Rect footerRect = new Rect(0.0f, position.height - 18.0f, position.width, 20.0f);
                // 显示树的画布
                Rect canvasRect = new Rect(0.0f, navHistoryRect.yMax, position.width, position.height - (footerRect.height + navHistoryRect.height));

                // 元素GUI风格设置
                BTEditorStyle.EnsureStyle();
                m_grid.DrawGUI(position.size);
                m_graph.DrawGUI(canvasRect);
                m_canvas.HandleEvents(canvasRect, position.size);
                DrawNavigationHistory(navHistoryRect);
                DrawFooter(footerRect);
                DrawOptions(optionsRect);

                if (m_canvas.IsDebuging)
                {
                    OnRepaint();
                }
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            LogicObject lo = (LogicObject)target;

            if (EditorApplication.isPlaying)
            {
                if (!lo.ShowAttrs && GUILayout.Button("ShowAttributes"))
                {
                    lo.ShowAttrs = true;
                }
                if (lo.ShowAttrs && GUILayout.Button("HideAttributes"))
                {
                    lo.ShowAttrs = false;
                }
            }
            serializedObject.Update();

            GUI.enabled = !EditorApplication.isPlaying;
            GUI.color   = Color.white;

            serializedObject.ApplyModifiedProperties();
            var agent = lo.so.GetComponent <AIAgent>();

            if (agent != null)
            {
                BTAsset       btAsset    = agent.BehaviourTree as BTAsset;
                BehaviourTree btInstance = agent.GetBehaviourTree();

                GUI.enabled = btAsset != null;
                if (EditorApplication.isPlaying && btInstance != null)
                {
                    if (GUILayout.Button("Preview", GUILayout.Height(24.0f)))
                    {
                        BehaviourTreeEditor.OpenDebug(btAsset, btInstance);
                    }
                }
                else
                {
                    if (GUILayout.Button("Edit", GUILayout.Height(24.0f)))
                    {
                        BehaviourTreeEditor.Open(btAsset);
                    }
                }
            }

            if (m_inspector != null)
            {
                BTEditorStyle.EnsureStyle();
                m_inspector.DrawGUI();
                Repaint();
            }
            else
            {
                EditorGUILayout.HelpBox("There are no values to display!", MessageType.Error);
            }
            GUI.enabled = true;
        }
コード例 #3
0
 public override void OnInspectorGUI()
 {
     if (m_inspector != null)
     {
         BTEditorStyle.EnsureStyle();
         m_inspector.DrawGUI();
         Repaint();
     }
     else
     {
         EditorGUILayout.HelpBox("There are no values to display!", MessageType.Error);
     }
 }