コード例 #1
0
        /// <summary>
        /// 查找资源的依赖,并生成默认的分组,将依赖的资源也单独打包处理
        /// </summary>
        /// <param name="isShowProgressBar"></param>
        internal static void FindAndAddAutoGroup(bool isShowProgressBar = false)
        {
            DeleteAutoGroup();

            AssetBundleTagConfig tagConfig = Util.FileUtil.ReadFromBinary <AssetBundleTagConfig>(BundlePackUtil.GetTagConfigPath());
            AssetDependFinder    finder    = CreateAssetDependFinder(tagConfig, isShowProgressBar);

            Dictionary <string, int> repeatAssetDic = finder.GetRepeatUsedAssets();

            AssetBundleGroupData gData = new AssetBundleGroupData();

            gData.GroupName = AUTO_REPEAT_GROUP_NAME;
            gData.IsMain    = false;

            foreach (var kvp in repeatAssetDic)
            {
                AssetAddressData aaData = new AssetAddressData();
                aaData.AssetAddress = aaData.AssetPath = kvp.Key;
                aaData.BundlePath   = HashHelper.Hash_MD5_32(kvp.Key, false);//AssetDatabase.AssetPathToGUID(kvp.Key);
                gData.AssetDatas.Add(aaData);
            }

            if (gData.AssetDatas.Count > 0)
            {
                tagConfig.GroupDatas.Add(gData);
            }

            Util.FileUtil.SaveToBinary <AssetBundleTagConfig>(BundlePackUtil.GetTagConfigPath(), tagConfig);
        }
コード例 #2
0
        protected override void RowGUI(RowGUIArgs args)
        {
            var item = (TreeViewItem <TreeElementWithData <AssetBundleGroupTreeData> >)args.item;
            AssetBundleGroupTreeData groupTreeData = item.data.Data;

            Rect contentRect = args.rowRect;

            contentRect.x     += GetContentIndent(item);
            contentRect.width -= GetContentIndent(item);

            GUILayout.BeginArea(contentRect);
            {
                AssetBundleGroupData groupData = groupTreeData.GroupData;
                if (groupTreeData.IsGroup)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        string groupName = groupData.GroupName;
                        if (groupData.IsMain)
                        {
                            groupName += "(Main)";
                        }
                        groupName += "  " + groupData.AssetDatas.Count;
                        EditorGUILayout.LabelField(new GUIContent(groupName));
                        if (groupTreeData.IsAddressRepeat)
                        {
                            if (GUILayout.Button(m_AddressRepeatContent))
                            {
                                SetExpanded(args.item.id, true);
                            }
                        }
                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (groupTreeData.IsAddressRepeat)//如果资源有重复的添加提示
                        {
                            if (GUILayout.Button(m_AddressRepeatContent, GUILayout.Width(24)))
                            {
                                Vector2 pos = GUIUtility.GUIToScreenPoint(Input.mousePosition);
                                AssetAddressRepeatPopupWindow.GetWindow().ShowWithParam(groupTreeData.RepeatAddressList, pos);
                            }
                        }
                        else
                        {
                            GUILayout.Label(GUIContent.none, GUILayout.Width(24));
                        }

                        EditorGUIUtil.BeginLabelWidth(60);
                        {
                            AssetAddressData assetData = groupData.AssetDatas[groupTreeData.DataIndex];
                            EditorGUILayout.LabelField(new GUIContent("" + groupTreeData.DataIndex), GUILayout.Width(20));
                            EditorGUILayout.TextField("address:", assetData.AssetAddress);
                            GUILayout.BeginVertical();
                            {
                                EditorGUILayout.TextField("path:", assetData.AssetPath);
                                EditorGUILayout.TextField("bundle:", assetData.BundlePath);
                                EditorGUILayout.TextField("labels:", string.Join(",", assetData.Labels));
                            }
                            GUILayout.EndVertical();
                        }
                        EditorGUIUtil.EndLableWidth();
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndArea();
        }
コード例 #3
0
        /// <summary>
        /// 生成TreeView需要的数据
        /// </summary>
        private void FilterTreeModel()
        {
            TreeModel <TreeElementWithData <AssetBundleGroupTreeData> > treeModel = m_DetailGroupTreeView.treeModel;
            TreeElementWithData <AssetBundleGroupTreeData> treeModelRoot          = treeModel.root;

            treeModelRoot.children?.Clear();

            if (m_TagConfig.GroupDatas == null)
            {
                return;
            }

            List <AssetAddressData> dataList = (from groupData in m_TagConfig.GroupDatas where groupData.IsMain
                                                from detailData in groupData.AssetDatas
                                                select detailData).ToList();

            for (int i = 0; i < m_TagConfig.GroupDatas.Count; i++)
            {
                AssetBundleGroupData groupData = m_TagConfig.GroupDatas[i];
                TreeElementWithData <AssetBundleGroupTreeData> groupElementData = new TreeElementWithData <AssetBundleGroupTreeData>(
                    new AssetBundleGroupTreeData()
                {
                    IsGroup   = true,
                    GroupData = groupData,
                }, "", 0, (i + 1) * 100);

                treeModel.AddElement(groupElementData, treeModelRoot, treeModelRoot.hasChildren ? treeModelRoot.children.Count : 0);

                bool isAddressRepeat = false;
                for (int j = 0; j < groupData.AssetDatas.Count; ++j)
                {
                    AssetAddressData        detailData = groupData.AssetDatas[j];
                    List <AssetAddressData> repeatList = (from data in dataList
                                                          where data.AssetAddress == detailData.AssetAddress
                                                          select data).ToList();

                    if (FilterAssetDetailData(detailData))
                    {
                        TreeElementWithData <AssetBundleGroupTreeData> elementData = new TreeElementWithData <AssetBundleGroupTreeData>(
                            new AssetBundleGroupTreeData()
                        {
                            IsGroup   = false,
                            DataIndex = j,
                            GroupData = groupData,
                        }, "", 1, (i + 1) * 100 + (j + 1));

                        if (repeatList.Count > 1)
                        {
                            elementData.Data.IsAddressRepeat   = true;
                            elementData.Data.RepeatAddressList = repeatList;
                            if (!isAddressRepeat)
                            {
                                isAddressRepeat = true;
                            }
                        }

                        treeModel.AddElement(elementData, groupElementData, groupElementData.hasChildren ? groupElementData.children.Count : 0);
                    }
                }
                groupElementData.Data.IsAddressRepeat = isAddressRepeat;
            }
        }