void OnGUI() { // 初始化 if (_isInit == false) { _isInit = true; Init(); } // 列表显示 EditorGUILayout.Space(); for (int i = 0; i < AssetScanerSettingData.Setting.Elements.Count; i++) { string directory = AssetScanerSettingData.Setting.Elements[i].ScanerDirectory; string scanerName = AssetScanerSettingData.Setting.Elements[i].ScanerName; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(directory); int index = NameToIndex(scanerName); int newIndex = EditorGUILayout.Popup(index, _classArray, GUILayout.MaxWidth(150)); if (newIndex != index) { string newScanerName = IndexToName(newIndex); AssetScanerSettingData.ModifyElement(directory, newScanerName); } if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { AssetScanerSettingData.RemoveElement(directory); break; } } EditorGUILayout.EndHorizontal(); } // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("+", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); AssetScanerSettingData.AddElement(_lastOpenFolderPath); } } // 扫描按钮 if (GUILayout.Button("Scan")) { _results = AssetScanerSettingData.ScanAllAssets(); } // 绘制扫描结果 DrawResults(); }
private void Init() { List <string> names = AssetScanerSettingData.GetScanerNames(); _classArray = names.ToArray(); }