/// <summary> /// 读取AB包配置信息 /// </summary> public static void ReadAssetBundleConfig() { string[] names = AssetDatabase.GetAllAssetBundleNames(); for (int i = 0; i < names.Length; i++) { EditorUtility.DisplayProgressBar("Hold On", "Collect AssetBundle Config[" + i + "/" + names.Length + "]......", (float)i / names.Length); BundleInfo build = GetBundleInfoByName(names[i]); string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundle(names[i]); for (int j = 0; j < assetPaths.Length; j++) { build.AddAsset(assetPaths[j]); } } EditorUtility.ClearProgressBar(); }
private void AssetPropertyGUI() { if (_currentFile != null) { _currentFile.ReadDependenciesFile(); GUI.color = (_currentFile.IsRedundant ? Color.red : Color.white); _assetPropertyViewRect = new Rect((int)position.width - 420, 50, 400, 400); _assetPropertyScrollRect = new Rect((int)position.width - 420, 50, 400, _assetPropertyViewHeight); _assetPropertyScroll = GUI.BeginScrollView(_assetPropertyViewRect, _assetPropertyScroll, _assetPropertyScrollRect); GUI.BeginGroup(_assetPropertyScrollRect, _helpBox); _assetPropertyViewHeight = 5; GUIContent content = EditorGUIUtility.ObjectContent(null, _currentFile.AssetType); content.text = _currentFile.Name; GUI.Label(new Rect(5, _assetPropertyViewHeight, 40, 15), "Asset:"); if (GUI.Button(new Rect(50, _assetPropertyViewHeight, 280, 15), content, _prefabLabel)) { Selection.activeObject = _currentFile.AssetObject; EditorGUIUtility.PingObject(_currentFile.AssetObject); } GUI.enabled = (_currentAB != null && _currentFile.Bundled == ""); if (GUI.Button(new Rect(340, _assetPropertyViewHeight, 50, 15), "Bundle", _preButton)) { _currentAB.AddAsset(_currentFile.AssetPath); _currentFile = null; return; } GUI.enabled = true; _assetPropertyViewHeight += 20; GUI.Label(new Rect(5, _assetPropertyViewHeight, 330, 15), "Path: " + _currentFile.AssetPath); if (GUI.Button(new Rect(340, _assetPropertyViewHeight, 50, 15), "Copy", _preButton)) { GUIUtility.systemCopyBuffer = _currentFile.AssetPath; } _assetPropertyViewHeight += 20; if (_currentFile.Dependencies.Count > 0) { _isShowDependencies = EditorGUI.Foldout(new Rect(5, _assetPropertyViewHeight, 390, 15), _isShowDependencies, "Dependencies:", true); _assetPropertyViewHeight += 20; if (_isShowDependencies) { for (int i = 0; i < _currentFile.Dependencies.Count; i++) { AssetFileInfo file = AssetBundleEditorUtility.GetFileInfoByPath(_currentFile.Dependencies[i]); content = EditorGUIUtility.ObjectContent(null, file.AssetType); content.text = file.Name; if (GUI.Button(new Rect(45, _assetPropertyViewHeight, 350, 15), content, _prefabLabel)) { Selection.activeObject = file.AssetObject; EditorGUIUtility.PingObject(file.AssetObject); } _assetPropertyViewHeight += 20; } } } if (_currentFile.IndirectBundledRelation.Count > 0) { _isShowIndirectBundled = EditorGUI.Foldout(new Rect(5, _assetPropertyViewHeight, 390, 15), _isShowIndirectBundled, "Indirect Bundled:", true); _assetPropertyViewHeight += 20; if (_isShowIndirectBundled) { foreach (KeyValuePair <string, string> bundle in _currentFile.IndirectBundledRelation) { AssetFileInfo file = AssetBundleEditorUtility.GetFileInfoByPath(bundle.Key); content = EditorGUIUtility.ObjectContent(null, file.AssetType); content.text = file.Name + " >> " + bundle.Value; if (GUI.Button(new Rect(45, _assetPropertyViewHeight, 350, 15), content, _prefabLabel)) { Selection.activeObject = file.AssetObject; EditorGUIUtility.PingObject(file.AssetObject); } _assetPropertyViewHeight += 20; } } } _assetPropertyViewHeight += 5; if (_assetPropertyViewHeight < _assetPropertyViewRect.height) { _assetPropertyViewHeight = (int)_assetPropertyViewRect.height; } GUI.EndGroup(); GUI.EndScrollView(); GUI.color = Color.white; } }