/// <summary> /// 通过名称删除AB包对象 /// </summary> public static void DeleteBundleInfoByName(string bundleName) { if (_bundleInfos.ContainsKey(bundleName)) { BundleInfo bundle = _bundleInfos[bundleName]; bundle.ClearAsset(); _bundleInfos.Remove(bundleName); BundleInfosList.Remove(bundle); AssetDatabase.RemoveAssetBundleName(bundleName, true); } }
private void TitleGUI() { if (GUI.Button(new Rect(5, 5, 60, 15), "Create", _preButton)) { AssetBundleEditorUtility.GetBundleInfoByName("ab" + System.DateTime.Now.ToString("yyyyMMddHHmmssfff")); } GUI.enabled = (_currentAB != null); if (GUI.Button(new Rect(65, 5, 60, 15), "Rename", _preButton)) { _isRename = !_isRename; } if (GUI.Button(new Rect(125, 5, 60, 15), "Clear", _preButton)) { if (EditorUtility.DisplayDialog("Prompt", "Clear " + _currentAB + " ?", "Yes", "No")) { _currentAB.ClearAsset(); } } if (GUI.Button(new Rect(185, 5, 60, 15), "Delete", _preButton)) { if (EditorUtility.DisplayDialog("Prompt", "Delete " + _currentAB + "?this will clear all assets!and this operation cannot be restore!", "Yes", "No")) { AssetBundleEditorUtility.DeleteBundleInfoByName(_currentAB.Name); _currentAB = null; } } GUI.enabled = true; _hideInvalidAsset = GUI.Toggle(new Rect(265, 5, 100, 15), _hideInvalidAsset, "Hide Invalid"); _hideBundleAsset = GUI.Toggle(new Rect(365, 5, 100, 15), _hideBundleAsset, "Hide Bundled"); _showOnlyRedundant = GUI.Toggle(new Rect(465, 5, 200, 15), _showOnlyRedundant, "Show Only Redundant"); GUI.Label(new Rect(5, 25, 60, 15), "Variant:"); _variant = EditorGUI.TextField(new Rect(70, 25, 110, 15), _variant); if (GUI.Button(new Rect(185, 25, 60, 15), "Apply", _preButton)) { EditorPrefs.SetString(EditorPrefsTable.AssetBundleEditor_Variant, _variant); } if (GUI.Button(new Rect(250, 25, 60, 15), "Open", _preButton)) { AssetBundleEditorUtility.OpenFolder(_buildPath); } if (GUI.Button(new Rect(310, 25, 60, 15), "Browse", _preButton)) { string path = EditorUtility.OpenFolderPanel("Select Path", Application.dataPath, ""); if (path.Length != 0) { _buildPath = path; EditorPrefs.SetString(EditorPrefsTable.AssetBundleEditor_BuildPath, _buildPath); } } GUI.Label(new Rect(370, 25, 70, 15), "Build Path:"); GUI.TextField(new Rect(440, 25, 300, 15), _buildPath); BuildTarget buildTarget = (BuildTarget)EditorGUI.EnumPopup(new Rect((int)position.width - 205, 5, 150, 15), _buildTarget, _preDropDown); if (buildTarget != _buildTarget) { _buildTarget = buildTarget; EditorPrefs.SetInt(EditorPrefsTable.AssetBundleEditor_BuildTarget, (int)_buildTarget); } if (GUI.Button(new Rect((int)position.width - 55, 5, 50, 15), "Build", _preButton)) { AssetBundleEditorUtility.BuildAssetBundles(); } }