void OnEnable() { variableAll = EditorPrefs.GetBool(VARIABLEALL, true); propertyAll = EditorPrefs.GetBool(PROPERTYALL, true); eventAll = EditorPrefs.GetBool(EVENTALL, true); isExpandAll = EditorPrefs.GetBool(ISEXPANDALL, false); if (m_TreeViewState == null) { m_TreeViewState = new UITreeViewState(); } //每次打开或者有脚本重新加载的时候 都会tree形态重新绘制 痛点 要把数据保存 uiTreeView = new UITreeview(m_TreeViewState); m_SearchField = new SearchField(); m_SearchField.downOrUpArrowKeyPressed += uiTreeView.SetFocusAndEnsureSelectedItem; }
//初始化 public UITreeview(TreeViewState treeViewState) : base(treeViewState) { uitreeViewState = treeViewState as UITreeViewState; Reload(); rowHeight = 20f; //行高 if (isFirstInit) { ExpandAll(); } else { SetExpanded(0, true); foreach (var item in allItems) { UITreeViewItem uitreeitem = (item as UITreeViewItem); SetExpanded(uitreeitem.id, uitreeitem.isExpand); } } }