Example #1
0
        public void DrawGUI(Vector2 windowSize)
        {
            BTEditorCanvas canvas    = BTEditorCanvas.Current;
            Rect           position  = new Rect(0, 0, windowSize.x, windowSize.y);
            Rect           texCoords = new Rect(-canvas.Position.x / m_gridTexture.width,
                                                (1.0f - windowSize.y / m_gridTexture.height) + canvas.Position.y / m_gridTexture.height,
                                                windowSize.x / m_gridTexture.width,
                                                windowSize.y / m_gridTexture.height);

            GUI.DrawTextureWithTexCoords(position, m_gridTexture, texCoords);
        }
        private void OnEnable()
        {
            if (m_gridTexture == null)
            {
                m_gridTexture = Resources.Load <Texture>("BevTree/EditorGUI/background");
            }

            if (m_graph == null)
            {
                m_graph = BTEditorGraph.Create();
            }
            if (m_canvas == null)
            {
                m_canvas = new BTEditorCanvas();
                BTEditorCanvas.Current = m_canvas;
            }
            if (m_hotkeyHandler == null)
            {
                m_hotkeyHandler = new BTEditorHotKeyHandler(m_graph);
            }
            if (m_grid == null)
            {
                m_grid = new BTEditorGrid(m_gridTexture);
            }
            if (m_navigationHistory == null)
            {
                m_navigationHistory = new BTNavigationHistory();
            }

            ReloadBehaviourTree();
            m_isDisposed        = false;
            m_canvas.OnRepaint += OnRepaint;
            EditorApplication.playmodeStateChanged += HandlePlayModeChanged;

            // debugging
            Selection.selectionChanged += delegate { SetupBTDebugging(); };
        }