private void OnEnable() { if (_groups == null) { try { Context.Init(); _groups = Context.Groups .Distinct() .ToArray(); } catch (Exception e) { LogUtils.Verbose(e); _groups = null; } } if (_groups == null) { return; } _treeViewState = new TreeViewState(); _treeView = new GroupsTreeView(_groups, serializedObject); _treeView.Reload(); _searchField = new SearchField(); }
public override void OnInspectorGUI() { if (_groups == null || _groups.Length == 0) { DrawEmpty(); return; } if (Event.current.type == EventType.Layout) { if (_searchText != _treeViewState.searchString) { _reloadOnLayout = false; _treeViewState.searchString = _searchText; _treeView.Reload(); } if (_reloadOnLayout) { _reloadOnLayout = false; _treeView.Reload(); } } using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true))) { _searchText = _searchField.OnGUI(_searchText); GUILayout.Space(8); EditorGUI.BeginChangeCheck(); _treeView.OnGUILayout(GUILayout.ExpandWidth(true)); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); AssetDatabase.SaveAssets(); AssetDatabase.ImportAsset(Target.GetAssetPath()); _reloadOnLayout = true; } } }
private void OnEnable() { if (_roots == null) { try { _roots = new ProxyCodeGenerator { TargetAssemblies = AppDomain.CurrentDomain.GetAssemblies() } .GetRootDefinitions() .ToArray(); _groups = _roots .SelectMany(r => r.Attributes) .Select(a => a.Group) .Distinct() .ToArray(); } catch (Exception e) { if (YamlySettings.Instance.VerboseLogs) { Debug.LogException(e); } _roots = null; } } if (_roots == null) { return; } _treeViewState = new TreeViewState(); _treeView = new GroupsTreeView(_groups, serializedObject); _treeView.Reload(); _searchField = new SearchField(); }