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."); } } }