private void AssetBundlesGUI() { _ABViewRect = new Rect(5, 45, 240, (int)position.height / 2 - 40); _ABScrollRect = new Rect(5, 45, 240, _ABViewHeight); _ABScroll = GUI.BeginScrollView(_ABViewRect, _ABScroll, _ABScrollRect); GUI.BeginGroup(_ABScrollRect, _box); _ABViewHeight = 5; for (int i = 0; i < AssetBundleEditorUtility.BundleInfosList.Count; i++) { BundleInfo bundle = AssetBundleEditorUtility.BundleInfosList[i]; string icon = bundle.Count > 0 ? "Prefab Icon" : "GameObject Icon"; if (_currentAB == bundle) { GUI.Box(new Rect(0, _ABViewHeight, 240, 15), "", _LRSelect); if (_isRename) { GUIContent content = EditorGUIUtility.IconContent(icon); content.text = ""; GUI.Label(new Rect(5, _ABViewHeight, 230, 15), content, _prefabLabel); _renameValue = EditorGUI.TextField(new Rect(40, _ABViewHeight, 140, 15), _renameValue); if (GUI.Button(new Rect(180, _ABViewHeight, 30, 15), "OK", _miniButtonLeft)) { if (_renameValue != "") { if (!AssetBundleEditorUtility.IsExistBundleInfo(_renameValue)) { AssetBundleEditorUtility.RenameBundleInfo(_currentAB.Name, _renameValue); _renameValue = ""; _isRename = false; } else { GlobalTools.LogError("Already existed AssetBundle name:" + _renameValue); } } } if (GUI.Button(new Rect(210, _ABViewHeight, 30, 15), "NO", _miniButtonRight)) { _isRename = false; } } else { GUIContent content = EditorGUIUtility.IconContent(icon); content.text = bundle.Name; GUI.Label(new Rect(5, _ABViewHeight, 230, 15), content, _prefabLabel); } } else { GUIContent content = EditorGUIUtility.IconContent(icon); content.text = bundle.Name; if (GUI.Button(new Rect(5, _ABViewHeight, 230, 15), content, _prefabLabel)) { _currentAB = bundle; _currentABFile = null; _isRename = false; } } _ABViewHeight += 20; } _ABViewHeight += 5; if (_ABViewHeight < _ABViewRect.height) { _ABViewHeight = (int)_ABViewRect.height; } GUI.EndGroup(); GUI.EndScrollView(); }
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); } GUI.enabled = !EditorApplication.isPlaying; if (GUI.Button(new Rect((int)position.width - 55, 5, 50, 15), "Build", _preButton)) { AssetBundleEditorUtility.BuildAssetBundles(); } GUI.enabled = true; }