/// <summary> /// Search all asset if match rule /// </summary> /// <param name="folder"></param> /// <param name="filePaths"></param> protected void searchFiles(string folder, ABaseRule[] rules, Dictionary <ABaseRule, List <string> > filePaths) { for (int i = 0; i < rules.Length; i++) { string[] subFilePaths = Directory.GetFiles(folder, "*" + rules[i].Suffix, SearchOption.TopDirectoryOnly); List <string> paths = null; if (!filePaths.TryGetValue(rules[i], out paths)) { paths = new List <string>(); filePaths[rules[i]] = paths; } paths.AddRange(subFilePaths); } string[] childFolders = Directory.GetDirectories(folder); AssetImporterWindow aiw = AssetImporterWindow.Instance; string dataPath = Application.dataPath; for (int i = 0; i < childFolders.Length; i++) { string relativePath = childFolders[i].Replace(dataPath, "Assets"); if (aiw.HasRules <T>(relativePath)) { // skip this folder if it have new rules continue; } searchFiles(childFolders[i], rules, filePaths); } }
private void OnEnable() { asw = this; this.initAllRules(); panelState = ImportPreferences.EPanel.Texture; }
public FolderTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader, TreeModel <FolderElement> model) : base(state, multiColumnHeader, model) { // Custom setup rowHeight = kRowHeights; columnIndexForTreeFoldouts = 0; showAlternatingRowBackgrounds = true; showBorder = true; customFoldoutYOffset = (kRowHeights - EditorGUIUtility.singleLineHeight) * 0.5f; // center foldout in the row since we also center content. See RowGUI extraSpaceBeforeIconAndLabel = kIconWidth; aiw = AssetImporterWindow.Instance; this.Reload(); }
private void onAddRuleGUI() { AssetImporterWindow aiw = AssetImporterWindow.Instance; string[] rules = aiw.GetRuleKeys <T>(); defaultRuleIndex = EditorGUILayout.Popup("Rules", defaultRuleIndex, rules); if (defaultRuleIndex != 0) { curRule = aiw.GetRule <T>(rules[defaultRuleIndex]); GUILayoutHelper.DrawSeparator(); EditorGUILayout.BeginVertical("Box"); this.OnRuleGUI(curRule); EditorGUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayoutHelper.DrawSeparator(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(ImportPreferences.BtnApply, GUILayout.MaxWidth(80))) { ruleTabs.Add(curRule.RuleKey); curRuleTab = curRule.RuleKey; keyRules[curRuleTab] = curRule; string relativePath = this.curSelectFolder.RelativePath; string[] sfr = new string[curRule.Folders.Length + 1]; Array.Copy(curRule.Folders, sfr, curRule.Folders.Length); sfr[sfr.Length - 1] = relativePath; curRule.Folders = sfr; AssetImporterWindow.Instance.AddFolderRule(relativePath, curRule); ApplyFolder(curRule, relativePath); EditorUtility.SetDirty(curRule); } EditorGUILayout.EndHorizontal(); } }
protected void initFolderTree(List <FolderElement> folders) { treeviewState = new TreeViewState(); AssetImporterWindow window = AssetImporterWindow.Instance; Rect windowRect = window.position; TreeModel <FolderElement> treeModel = new TreeModel <FolderElement>(folders); Rect mulHeaderRect = multiColumnTreeViewRect(ref windowRect); MultiColumnHeaderState mulHeader = CreateDefaultMultiColumnHeaderState(mulHeaderRect.width); MultiColumnHeader multiColumnHeader = new MultiColumnHeader(mulHeader); folderTree = new FolderTreeView(treeviewState, multiColumnHeader, treeModel); folderTree.clickItem += OnClickFolderTreeItem; folderTree.ReimportFolderEvent += reimportFolder; // folderTree.SetExpanded(1, true); OnClickFolderTreeItem(treeModel.Find(1)); }
/// <summary> /// Search all asset if match rule /// </summary> /// <param name="rule"></param> /// <param name="paths"></param> protected void searchFiles(string folder, string suffix, List <string> paths) { AssetImporterWindow aiw = AssetImporterWindow.Instance; string dataPath = Application.dataPath; string[] subFilePaths = Directory.GetFiles(folder, "*" + suffix, SearchOption.TopDirectoryOnly); paths.AddRange(subFilePaths); string[] childFolders = Directory.GetDirectories(folder); for (int j = 0; j < childFolders.Length; j++) { string relativePath = childFolders[j].Replace(dataPath, "Assets"); if (aiw.HasRules <T>(relativePath)) { // skip this folder if it have new rules continue; } searchFiles(childFolders[j], suffix, paths); } }
private void OnDestroy() { asw = null; }
private static void showWindow() { AssetImporterWindow window = EditorWindow.GetWindow <AssetImporterWindow>("Asset Importer"); window.Show(); }