private void OnEnable() { titleContent = new GUIContent("Layer Manager", EditorGUIUtility.IconContent("ToggleUVOverlay").image); if (_layerHandler == null) { _layerHandler = new LayerHandler(); } if (_searchField == null) { _searchField = new SearchField(); } _treeView = new LayerTreeView(_layerHandler.TreeRoot); // Notify the tree That the table has changed (mainly to reset the state) _layerHandler.TableChanged += _treeView.TableChanged; // reload when the layer handler has rebuilt its tree _layerHandler.TreeRebuilt += _treeView.Reload; // notify the treeview to set selection on the new layer _layerHandler.LayerCreated += _treeView.LayerCreated; // notify the treeview to set focus on the layer where the items are assigned and to set seleiton on items _layerHandler.ItemsAssigned += _treeView.ItemsAssigned; // trigger layer updates when layer was renamed _treeView.LayerRenamed += _layerHandler.OnLayerRenamed; // select layer items / selected item when layer / item was double-clicked _treeView.ItemDoubleClicked += LayerHandler.OnItemDoubleClicked; // assign new layer when item was dropped onto a layer _treeView.ItemsDropped += _layerHandler.OnItemsDropped; // show context menu _treeView.ItemContextClicked += OnContextClicked; _searchField.downOrUpArrowKeyPressed += _treeView.SetFocusAndEnsureSelectedItem; ItemInspector.ItemRenamed += _treeView.OnItemRenamed; // repaint layer when visibility changes SceneVisibilityManager.visibilityChanged += OnVisibilityChanged; // reload when undo performed Undo.undoRedoPerformed += OnUndoRedoPerformed; // catch ToolBoxEditor item creation event to assign to the currently selected layer ToolboxEditor.ItemCreated += ToolBoxItemCreated; // will notify the TreeView if Synchronize Selection is set Selection.selectionChanged += SelectionChanged; // auto select a table to show data for FindTable(); }
private void OnEnable() { if (_layerHandler == null) { _layerHandler = new LayerHandler(); } if (_searchField == null) { _searchField = new SearchField(); } _treeView = new LayerTreeView(_layerHandler.TreeRoot); // reload when the layer handler has rebuilt its tree _layerHandler.TreeRebuilt += _treeView.Reload; // trigger layer updates when layer was renamed _treeView.LayerRenamed += _layerHandler.OnLayerRenamed; // select layer items / selected item when layer / item was double-clicked _treeView.ItemDoubleClicked += LayerHandler.OnItemDoubleClicked; // assign new layer when item was dropped onto a layer _treeView.ItemsDropped += _layerHandler.OnItemsDropped; // show context menu _treeView.ItemContextClicked += OnContextClicked; _searchField.downOrUpArrowKeyPressed += _treeView.SetFocusAndEnsureSelectedItem; // repaint layer when visibility changes SceneVisibilityManager.visibilityChanged += OnVisibilityChanged; // reload when undo performed Undo.undoRedoPerformed += OnUndoRedoPerformed; // trigger handler update on enable OnHierarchyChange(); }