private void Init() { _assetRootFolder = AssetBundleEditorUtility.GetFolderInfoByFullPath(Application.dataPath); AssetBundleEditorUtility.ReadAssetBundleConfig(); _buildPath = EditorPrefs.GetString(EditorPrefsTable.AssetBundleEditor_BuildPath, Application.streamingAssetsPath); _buildTarget = (BuildTarget)EditorPrefs.GetInt(EditorPrefsTable.AssetBundleEditor_BuildTarget, 5); _variant = EditorPrefs.GetString(EditorPrefsTable.AssetBundleEditor_Variant, ""); _box = new GUIStyle("Box"); _helpBox = new GUIStyle("HelpBox"); _preButton = new GUIStyle("PreButton"); _preDropDown = new GUIStyle("PreDropDown"); _LRSelect = new GUIStyle("LODSliderRangeSelected"); _prefabLabel = new GUIStyle("PR PrefabLabel"); _label = new GUIStyle("PR Label"); _brokenPrefabLabel = new GUIStyle("PR BrokenPrefabLabel"); _miniButtonLeft = new GUIStyle("MiniButtonLeft"); _miniButtonRight = new GUIStyle("MiniButtonRight"); _oLMinus = new GUIStyle("OL Minus"); _assetLabel = new GUIStyle("AssetLabel"); _redundant = EditorGUIUtility.IconContent("lightMeter/redLight"); _redundant.text = "Redundant"; }
/// <summary> /// 读取资源文件夹下的子资源 /// </summary> public static void ReadAssetsInChildren(AssetFolderInfo folder) { DirectoryInfo di = new DirectoryInfo(folder.FullPath); FileSystemInfo[] fileinfos = di.GetFileSystemInfos(); for (int i = 0; i < fileinfos.Length; i++) { EditorUtility.DisplayProgressBar("Hold On", "Collect Assets[" + i + "/" + fileinfos.Length + "]......", (float)i / fileinfos.Length); if (fileinfos[i] is DirectoryInfo) { if (IsValidFolder(fileinfos[i].Name)) { AssetFolderInfo fi = GetFolderInfoByFullPath(fileinfos[i].FullName); folder.ChildAsset.Add(fi); } } else { if (fileinfos[i].Extension != ".meta") { AssetFileInfo fi = GetFileInfoByPath(GetAssetPathByFullPath(fileinfos[i].FullName)); folder.ChildAsset.Add(fi); } } } EditorUtility.ClearProgressBar(); }
private void AssetGUI(AssetInfoBase asset, int indentation) { AssetFileInfo fileInfo = asset as AssetFileInfo; AssetFolderInfo folderInfo = asset as AssetFolderInfo; if (fileInfo != null) { if ((_hideInvalidAsset && !fileInfo.IsValid) || (_hideBundleAsset && fileInfo.Bundled != "")) { return; } } GUILayout.BeginHorizontal(); GUILayout.Space(indentation * 20 + 5); if (folderInfo != null) { GUIContent content = EditorGUIUtility.IconContent("Folder Icon"); content.text = folderInfo.Name; folderInfo.IsExpanding = EditorGUILayout.Foldout(folderInfo.IsExpanding, content, true); } else { GUI.enabled = fileInfo.IsValid; GUI.color = (_currentFile == fileInfo ? Color.cyan : (fileInfo.IsRedundant ? Color.red : Color.white)); GUILayout.Space(10); GUIContent content = EditorGUIUtility.ObjectContent(null, fileInfo.AssetType); content.text = fileInfo.Name; if (GUILayout.Button(content, _prefabLabel, GUILayout.Height(20))) { _currentFile = fileInfo; } if (fileInfo.Bundled != "") { GUILayout.Label("[" + fileInfo.Bundled + "]", _prefabLabel); } GUI.color = Color.white; GUI.enabled = true; if (fileInfo.IsRedundant) { GUILayout.Label(_redundant, _brokenPrefabLabel, GUILayout.Height(20)); } } _assetViewHeight += 20; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (folderInfo != null && folderInfo.IsExpanding) { folderInfo.ReadChildAsset(); for (int i = 0; i < folderInfo.ChildAsset.Count; i++) { AssetGUI(folderInfo.ChildAsset[i], indentation + 1); } } }
/// <summary> /// 通过全路径获取资源文件夹对象 /// </summary> public static AssetFolderInfo GetFolderInfoByFullPath(string fullPath) { if (_folderInfos.ContainsKey(fullPath)) { return(_folderInfos[fullPath]); } else { string name = Path.GetFileName(fullPath); AssetFolderInfo folder = new AssetFolderInfo(fullPath, name); _folderInfos.Add(fullPath, folder); return(folder); } }