private void Add() { string path = SelectFolder(); if (!string.IsNullOrEmpty(path)) { var rule = new ResourceRule(); rule.assetsDirectoryPath = path; m_Configuration.rules.Add(rule); } }
private void ApplyResourceFilter(ref List <string> signedResourceList, ResourceRule resourceRule, string resourceName, string singleAssetGUID = "", string childDirectoryPath = "") { if (!signedResourceList.Contains(Path.Combine(resourceRule.assetsDirectoryPath, resourceName))) { signedResourceList.Add(Path.Combine(resourceRule.assetsDirectoryPath, resourceName)); foreach (GFResource oldResource in GetResources()) { if (oldResource.Name == resourceName) { RenameResource(oldResource.Name, oldResource.Variant, resourceName, resourceRule.variant); break; } } if (!HasResource(resourceName, resourceRule.variant)) { AddResource(resourceName, resourceRule.variant, resourceRule.fileSystem, resourceRule.loadType, resourceRule.packed, resourceRule.groups.Split(';', ',', '|')); } switch (resourceRule.filterType) { case ResourceFilterType.Root: case ResourceFilterType.ChildrenFoldersOnly: string[] patterns = resourceRule.searchPatterns.Split(';', ',', '|'); if (childDirectoryPath == "") { childDirectoryPath = resourceRule.assetsDirectoryPath; } for (int i = 0; i < patterns.Length; i++) { FileInfo[] assetFiles = new DirectoryInfo(childDirectoryPath).GetFiles(patterns[i], SearchOption.AllDirectories); foreach (FileInfo file in assetFiles) { if (file.Extension.Contains("meta")) { continue; } string assetName = Path.Combine("Assets", file.FullName.Substring(Application.dataPath.Length + 1)); string assetGUID = AssetDatabase.AssetPathToGUID(assetName); if (!m_SourceAssetExceptTypeFilterGUIDArray.Contains(assetGUID) && !m_SourceAssetExceptLabelFilterGUIDArray.Contains(assetGUID)) { AssignAsset(assetGUID, resourceName, resourceRule.variant); } } } break; case ResourceFilterType.Children: case ResourceFilterType.ChildrenFilesOnly: { AssignAsset(singleAssetGUID, resourceName, resourceRule.variant); } break; } } }
private void OnListElementGUI(Rect rect, int index, bool isactive, bool isfocused) { const float GAP = 5; ResourceRule rule = m_Configuration.rules[index]; rect.y++; Rect r = rect; r.width = 16; r.height = 18; rule.valid = EditorGUI.Toggle(r, rule.valid); r.xMin = r.xMax + GAP; r.xMax = r.xMax + 425; float assetBundleNameLength = r.width; rule.name = EditorGUI.TextField(r, rule.name); r.xMin = r.xMax + GAP; r.xMax = r.xMin + 100; rule.loadType = (LoadType)EditorGUI.EnumPopup(r, rule.loadType); r.xMin = r.xMax + GAP + 15; r.xMax = r.xMin + 30; rule.packed = EditorGUI.Toggle(r, rule.packed); r.xMin = r.xMax + GAP; r.xMax = r.xMin + 85; rule.fileSystem = EditorGUI.TextField(r, rule.fileSystem); r.xMin = r.xMax + GAP; r.xMax = r.xMin + 85; rule.groups = EditorGUI.TextField(r, rule.groups); r.xMin = r.xMax + GAP; r.xMax = r.xMin + 85; rule.variant = EditorGUI.TextField(r, rule.variant.ToLower()); r.xMin = r.xMax + GAP; r.width = assetBundleNameLength - 15; GUI.enabled = false; rule.assetsDirectoryPath = EditorGUI.TextField(r, rule.assetsDirectoryPath); GUI.enabled = true; r.xMin = r.xMax + GAP; r.width = 50; if (GUI.Button(r, "Select")) { var path = SelectFolder(); if (path != null) { rule.assetsDirectoryPath = path; } } r.xMin = r.xMax + GAP; r.xMax = r.xMin + 85; rule.filterType = (ResourceFilterType)EditorGUI.EnumPopup(r, rule.filterType); r.xMin = r.xMax + GAP; r.xMax = rect.xMax; rule.searchPatterns = EditorGUI.TextField(r, rule.searchPatterns); }