Example #1
0
        private bool FilterBundleData(PackerBundleData bundleData)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                return(true);
            }

            if (searchCategory == SearchCategory.All || searchCategory == SearchCategory.Bundle)
            {
                if (bundleData.Path.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    return(true);
                }

                if (searchCategory == SearchCategory.Bundle)
                {
                    return(false);
                }
            }

            foreach (var assetData in bundleData.assetDatas)
            {
                if (FilterAddressData(assetData))
                {
                    return(true);
                }
            }
            return(false);
        }
        private void DrawBundleData(Rect contentRect, PackerBundleData bundleData, int childCount)
        {
            Rect drawRect = new Rect(contentRect.x, contentRect.y, contentRect.height, contentRect.height);

            drawRect.x    += drawRect.width + 5;
            drawRect.width = contentRect.width - drawRect.x;

            EditorGUI.LabelField(drawRect, new GUIContent($"{bundleData.Path}({childCount})"));
        }
Example #3
0
        private void SetTreeModel()
        {
            TreeModel <TreeElementWithData <AssetPackerTreeData> > treeModel = assetPackerTreeView.treeModel;
            TreeElementWithData <AssetPackerTreeData> treeModelRoot          = treeModel.root;

            treeModelRoot.children?.Clear();

            int id = 1;

            for (int i = 0; i < packerData.groupDatas.Count; ++i)
            {
                var groupData = packerData.groupDatas[i];
                if (FilterGroupData(groupData))
                {
                    AssetPackerTreeData groupTreeData = new AssetPackerTreeData();
                    groupTreeData.GroupIndex = i;

                    TreeElementWithData <AssetPackerTreeData> groupElementData = new TreeElementWithData <AssetPackerTreeData>(groupTreeData, "", 0, id);
                    treeModel.AddElement(groupElementData, treeModelRoot, treeModelRoot.hasChildren ? treeModelRoot.children.Count : 0);
                    id++;

                    for (int j = 0; j < groupData.bundleDatas.Count; j++)
                    {
                        PackerBundleData bundleData = groupData.bundleDatas[j];
                        if (FilterBundleData(bundleData))
                        {
                            AssetPackerTreeData bundleTreeData = new AssetPackerTreeData();
                            bundleTreeData.GroupIndex  = i;
                            bundleTreeData.BundleIndex = j;

                            TreeElementWithData <AssetPackerTreeData> bundleElementData = new TreeElementWithData <AssetPackerTreeData>(bundleTreeData, "", 0, id);
                            treeModel.AddElement(bundleElementData, groupElementData, groupElementData.hasChildren ? groupElementData.children.Count : 0);
                            id++;

                            for (int k = 0; k < bundleData.assetDatas.Count; k++)
                            {
                                PackerAssetData assetData = bundleData.assetDatas[k];
                                if (FilterAddressData(assetData))
                                {
                                    AssetPackerTreeData assetTreeData = new AssetPackerTreeData();
                                    assetTreeData.GroupIndex  = i;
                                    assetTreeData.BundleIndex = j;
                                    assetTreeData.AssetIndex  = k;

                                    TreeElementWithData <AssetPackerTreeData> assetElementData = new TreeElementWithData <AssetPackerTreeData>(assetTreeData, "", 0, id);
                                    treeModel.AddElement(assetElementData, bundleElementData, bundleElementData.hasChildren ? bundleElementData.children.Count : 0);
                                    id++;
                                }
                            }
                        }
                    }
                }
            }
        }
        public static PackerData GetPackerData()
        {
            AssetGroupCreater[] groups  = AssetDatabaseUtility.FindInstances <AssetGroupCreater>();
            List <AssetResult>  results = new List <AssetResult>();

            foreach (var group in groups)
            {
                results.AddRange(group.GetResults());
            }

            PackerData packerData = new PackerData();

            var groupNames = results.GroupBy((result) => result.GroupName).ToList();

            foreach (var gn in groupNames)
            {
                PackerGroupData groupData = new PackerGroupData();
                groupData.Name = gn.Key;
                packerData.groupDatas.Add(groupData);

                var bundleNames = gn.GroupBy((result) => result.Bundle).ToList();
                foreach (var bn in bundleNames)
                {
                    PackerBundleData bundleData = new PackerBundleData();
                    bundleData.Path = bn.Key;
                    groupData.bundleDatas.Add(bundleData);

                    foreach (var ad in bn)
                    {
                        PackerAssetData assetData = new PackerAssetData();
                        assetData.Address     = ad.Address;
                        assetData.Path        = ad.Path;
                        assetData.IsMainAsset = ad.IsMainAsset;
                        assetData.IsScene     = ad.IsScene;
                        assetData.Labels      = ad.Labels;

                        bundleData.assetDatas.Add(assetData);
                    }
                }
            }

            return(packerData);
        }