private void DrawAssetBundleFolder(AssetBundleFolder assetBundleFolder) { bool expand = IsExpandedAssetBundleFolder(assetBundleFolder); EditorGUILayout.BeginHorizontal(); { if (expand != EditorGUI.Foldout(new Rect(18f + 14f * assetBundleFolder.Depth, 20f * m_CurrentAssetBundleRowOnDraw + 2f, int.MaxValue, 14f), expand, string.Empty, true)) { expand = !expand; SetExpandedAssetBundleFolder(assetBundleFolder, expand); } GUI.DrawTexture(new Rect(32f + 14f * assetBundleFolder.Depth, 20f * m_CurrentAssetBundleRowOnDraw + 1f, 16f, 16f), AssetBundleFolder.Icon); EditorGUILayout.LabelField(string.Empty, GUILayout.Width(40f + 14f * assetBundleFolder.Depth), GUILayout.Height(18f)); EditorGUILayout.LabelField(assetBundleFolder.Name); } EditorGUILayout.EndHorizontal(); m_CurrentAssetBundleRowOnDraw++; if (expand) { foreach (AssetBundleFolder subAssetBundleFolder in assetBundleFolder.GetFolders()) { DrawAssetBundleFolder(subAssetBundleFolder); } foreach (AssetBundleItem assetBundleItem in assetBundleFolder.GetItems()) { DrawAssetBundleItem(assetBundleItem); } } }
public AssetBundleFolder(string name, AssetBundleFolder folder) { m_Folders = new List <AssetBundleFolder>(); m_Items = new List <AssetBundleItem>(); Name = name; Folder = folder; }
private void SetExpandedAssetBundleFolder(AssetBundleFolder assetBundleFolder, bool expand) { if (expand) { m_ExpandedAssetBundleFolderNames.Add(assetBundleFolder.FromRootPath); } else { m_ExpandedAssetBundleFolderNames.Remove(assetBundleFolder.FromRootPath); } }
private void OnEnable() { //创建控制器并注册事件 m_Controller = new AssetBundleEditorController(); m_Controller.EventOnLoadingAssetBundle += OnLoadingAssetBundle; m_Controller.EventOnLoadingAsset += OnLoadingAsset; m_Controller.EventOnLoadCompleted += OnLoadCompleted; m_Controller.EventOnAssetAssigned += OnAssetAssigned; m_Controller.EventOnAssetUnassigned += OnAssetUnassigned; m_MenuState = MenuState.Normal; m_SelectedAssetBundleInfo = null; m_AssetBundleRoot = new AssetBundleFolder("AssetBundles", null); m_ExpandedAssetBundleFolderNames = new HashSet <string>(); m_SelectedAssetsInSelectedAssetBundle = new HashSet <AssetInfo>(); m_ExpandedSourceFolders = new HashSet <SourceFolder>(); m_SelectedSourceAssets = new HashSet <SourceAsset>(); m_MissingSourceAssetIcon = EditorGUIUtility.IconContent("console.warnicon.sml").image; m_CachedSelectedSourceFolders = new HashSet <SourceFolder>(); m_CachedUnselectedSourceFolders = new HashSet <SourceFolder>(); m_CachedAssignedSourceFolders = new HashSet <SourceFolder>(); m_CachedUnassignedSourceFolders = new HashSet <SourceFolder>(); m_CachedAssignedSourceAssets = new HashSet <SourceAsset>(); m_CachedUnassignedSourceAssets = new HashSet <SourceAsset>(); m_AssetBundlesViewScroll = Vector2.zero; m_AssetBundleViewScroll = Vector2.zero; m_SourceAssetsViewScroll = Vector2.zero; m_InputAssetBundleName = null; m_InputAssetBundleVariant = null; m_HideAssignedSourceAssets = false; m_CurrentAssetBundleContentCount = 0; m_CurrentAssetBundleRowOnDraw = 0; m_CurrentSourceRowOnDraw = 0; if (m_Controller.Load()) { Debug.Log("Load configuration success."); } else { Debug.LogWarning("Load configuration failure."); } EditorUtility.DisplayProgressBar("Prepare AssetBundle Editor", "Processing...", 0f); RefreshAssetBundleTree(); EditorUtility.ClearProgressBar(); }
public AssetBundleItem(string name, AssetBundle assetBundle, AssetBundleFolder folder) { if (assetBundle == null) { throw new GameFrameworkException("AssetBundle is invalid."); } if (folder == null) { throw new GameFrameworkException("AssetBundle folder is invalid."); } Name = name; AssetBundle = assetBundle; Folder = folder; }
public AssetBundleFolder AddFolder(string name) { if (string.IsNullOrEmpty(name)) { throw new GameFrameworkException("AssetBundle folder name is invalid."); } AssetBundleFolder folder = GetFolder(name); if (folder != null) { throw new GameFrameworkException("AssetBundle folder is already exist."); } folder = new AssetBundleFolder(name, this); m_Folders.Add(folder); return(folder); }
private void RefreshAssetBundleTree() { m_AssetBundleRoot.Clear(); AssetBundle[] assetBundles = m_Controller.GetAssetBundles(); foreach (AssetBundle assetBundle in assetBundles) { string[] splitedPath = assetBundle.Name.Split('/'); AssetBundleFolder folder = m_AssetBundleRoot; for (int i = 0; i < splitedPath.Length - 1; i++) { AssetBundleFolder subFolder = folder.GetFolder(splitedPath[i]); folder = subFolder == null?folder.AddFolder(splitedPath[i]) : subFolder; } string assetBundleFullName = assetBundle.Variant != null?Utility.Text.Format("{0}.{1}", splitedPath[splitedPath.Length - 1], assetBundle.Variant) : splitedPath[splitedPath.Length - 1]; folder.AddItem(assetBundleFullName, assetBundle); } }
//刷新树状列表 private void RefreshAssetBundleTree() { m_AssetBundleRoot.Clear(); AssetBundleInfo[] assetBundleInfos = m_Controller.GetAssetBundleInfos(); foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { string[] splitPath = assetBundleInfo.Name.Split('/'); AssetBundleFolder folder = m_AssetBundleRoot; for (int i = 0; i < splitPath.Length - 1; i++) { AssetBundleFolder subFolder = folder.GetFolder(splitPath[i]); //获取存在的子文件夹 folder = subFolder == null?folder.AddFolder(splitPath[i]) : subFolder; //不存在则添加 } //最后添加Bundle全名 string assetBundleFullName = assetBundleInfo.Variant != null?Utility.Text.Format("{0}.{1}", splitPath[splitPath.Length - 1], assetBundleInfo.Variant) : splitPath[splitPath.Length - 1]; folder.AddItem(assetBundleFullName, assetBundleInfo); //添加Bundle资源项 } }
/// <summary> /// 收集资源组 /// </summary> private void _collectGroup(AssetBundleFolder assetBundleFolder) { foreach (AssetBundleFolder subAssetBundleFolder in assetBundleFolder.GetFolders()) { _collectGroup(subAssetBundleFolder); } foreach (AssetBundleItem assetBundleItem in assetBundleFolder.GetItems()) { var group = assetBundleItem.AssetBundle.GetResourceGroups(); foreach (var resourceGroup in group) { if (!_groups.Contains(resourceGroup)) { _groups.Add(resourceGroup); } } } }
private bool IsExpandedAssetBundleFolder(AssetBundleFolder assetBundleFolder) { return(m_ExpandedAssetBundleFolderNames.Contains(assetBundleFolder.FromRootPath)); }