Пример #1
0
        private void ImportLayout()
        {
            VisualElement root = rootVisualElement;

            // Import UXML
            var           visualTree   = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(Path.Combine(MainPaths.UxmlRoot, "BTWindowLayout.uxml"));
            VisualElement windowLayout = visualTree.Instantiate();

            root.Add(windowLayout);
            windowLayout.StretchToParentSize();

            // Import USS
            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(Path.Combine(MainPaths.UssRoot, "BTWindowStyles.uss"));

            root.styleSheets.Add(styleSheet);

            _graphContainer  = rootVisualElement.Q(name: "graph-container");
            _toolbar         = rootVisualElement.Q(className: "window-toolbar");
            _playmodeWatcher = _toolbar.Q <PlaymodeWatcher>();
            _treeSelector    = _toolbar.Q <TreeSelector>();

            _graph = new BTGraph();
            _graph.Initialize();
            _graphContainer.Add(_graph);
            _graph.OnStructureChanged += UpdatePlaymodeWatcher;
        }
Пример #2
0
        private void DisposeTree()
        {
            if (_graph != null)
            {
                _graph.OnStructureChanged -= UpdatePlaymodeWatcher;
                _graph.Dispose();
                _graph.SetEnabled(false);
                _graph.Unbind();
                _graph.RemoveFromHierarchy();
                _graphContainer.Clear();
                _graph = null;
            }

            _nodeHighlighter.Clear();
            SharedTree = null;

            _hasTreeInitialized = false;
        }