コード例 #1
0
        private void SetBTAssetDebug(BTAsset asset, BehaviourTree btInstance, bool clearNavigationHistory)
        {
            if (asset != null && btInstance != null && (clearNavigationHistory || asset != m_btAsset || !m_canvas.IsDebuging))
            {
                m_btAsset = asset;
                if (asset is RootTreeAsset)
                {
                    m_rootTreeAsset = asset as RootTreeAsset;
                }

                m_graph.SetBehaviourTree(asset, btInstance);
                m_canvas.Area = m_btAsset.CanvasArea;

                if (Mathf.Approximately(m_btAsset.CanvasPosition.x, 0) && Mathf.Approximately(m_btAsset.CanvasPosition.y, 0))
                {
                    m_canvas.CenterOnPosition(btInstance.Root.Position, position.size);
                }
                else
                {
                    m_canvas.Position = m_btAsset.CanvasPosition;
                }

                m_canvas.IsDebuging = true;

                if (clearNavigationHistory)
                {
                    m_navigationHistory.Clear();
                }

                m_navigationHistory.Push(m_btAsset, btInstance);
            }
        }
コード例 #2
0
        private void Dispose()
        {
            if (!m_isDisposed)
            {
                if (m_graph != null)
                {
                    BTEditorGraph.DestroyImmediate(m_graph);
                    m_graph = null;
                }
                if (m_btAsset != null)
                {
                    SaveBehaviourTree();
                    m_btAsset.Dispose();
                    m_btAsset = null;
                }

                m_rootTreeAsset = null;

                EditorApplication.playmodeStateChanged -= HandlePlayModeChanged;

                Selection.selectionChanged -= delegate { SetupBTDebugging(); };

                m_isDisposed = true;
            }
        }
コード例 #3
0
        private void SetBTAsset(BTAsset asset, bool clearNavigationHistory)
        {
            if (asset != null && (clearNavigationHistory || asset != m_btAsset))
            {
                if (m_btAsset != null)
                {
                    SaveBehaviourTree();
                    m_btAsset.Dispose();
                    m_btAsset = null;
                }

                BehaviourTree behaviourTree = asset.GetEditModeTree();
                if (behaviourTree != null)
                {
                    m_btAsset = asset;
                    if (asset is RootTreeAsset)
                    {
                        m_rootTreeAsset = asset as RootTreeAsset;
                    }
                    m_graph.SetBehaviourTree(asset, behaviourTree);
                    m_canvas.Area = m_btAsset.CanvasArea;

                    if (Mathf.Approximately(m_btAsset.CanvasPosition.x, 0) && Mathf.Approximately(m_btAsset.CanvasPosition.y, 0))
                    {
                        m_canvas.CenterOnPosition(behaviourTree.Root.Position, position.size);
                    }
                    else
                    {
                        m_canvas.Position = m_btAsset.CanvasPosition;
                    }

                    m_canvas.IsDebuging = false;

                    if (clearNavigationHistory)
                    {
                        m_navigationHistory.Clear();
                    }

                    m_navigationHistory.Push(m_btAsset, null);
                }
                else
                {
                    CrashEditor("Failed to deserialize behaviour tree!\n\nThis can happen when you rename a behaviour node class, when you change the namespace or when you delete a behaviour node script.\n\nTry to enable text serialization and manually edit the asset file to fix the behaviour tree.");
                }
            }
        }
コード例 #4
0
 private void OnEnable()
 {
     m_asset = target as RootTreeAsset;
 }