Пример #1
0
        private static List <AssetPackerAddressData> GetAssetsInGroup(AssetAddressGroup groupData)
        {
            List <string> assets = new List <string>();

            foreach (var filter in groupData.filters)
            {
                string[] finderAssets = filter.Filter();
                if (finderAssets != null && finderAssets.Length > 0)
                {
                    assets.AddRange(finderAssets);
                }
            }
            assets = assets.Distinct().ToList();

            List <AssetPackerAddressData> addressDatas = new List <AssetPackerAddressData>();

            foreach (var asset in assets)
            {
                AssetPackerAddressData data = new AssetPackerAddressData();
                data.assetPath     = asset;
                data.assetAddress  = groupData.operation.GetAddressName(asset);
                data.bundlePath    = groupData.operation.GetBundleName(asset);
                data.bundlePathMd5 = MD5Crypto.Md5(data.bundlePath).ToLower();
                data.labels        = groupData.operation.GetLabels();

                addressDatas.Add(data);
            }
            return(addressDatas);
        }
Пример #2
0
        private void SetTreeModel()
        {
            TreeModel <TreeElementWithData <AssetPackerTreeData> > treeModel = assetPackerTreeView.treeModel;
            TreeElementWithData <AssetPackerTreeData> treeModelRoot          = treeModel.root;

            treeModelRoot.children?.Clear();

            for (int i = 0; i < assetPackerConfig.groupDatas.Count; ++i)
            {
                AssetPackerGroupData groupData     = assetPackerConfig.groupDatas[i];
                AssetPackerTreeData  groupTreeData = new AssetPackerTreeData();
                groupTreeData.groupData = groupData;

                TreeElementWithData <AssetPackerTreeData> groupElementData = new TreeElementWithData <AssetPackerTreeData>(
                    groupTreeData, "", 0, (i + 1) * 100000);

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

                for (int j = 0; j < groupData.assetFiles.Count; ++j)
                {
                    AssetPackerAddressData addressData = groupData.assetFiles[j];
                    if (FilterAddressData(addressData))
                    {
                        AssetPackerTreeData elementTreeData = new AssetPackerTreeData();
                        elementTreeData.groupData = groupData;
                        elementTreeData.dataIndex = j;

                        TreeElementWithData <AssetPackerTreeData> elementData = new TreeElementWithData <AssetPackerTreeData>(
                            elementTreeData, "", 1, (i + 1) * 100000 + (j + 1));

                        treeModel.AddElement(elementData, groupElementData, groupElementData.hasChildren ? groupElementData.children.Count : 0);
                    }
                }
            }
        }
Пример #3
0
        private static void AddAddressGroup(AssetPackerConfig assetPackerConfig)
        {
            if (assetPackerConfig != null)
            {
                RemoveAddressGroup(assetPackerConfig);

                string[] assetPaths = AssetDatabaseUtility.FindAssets <AssetAddressConfig>();
                if (assetPaths == null || assetPaths.Length == 0)
                {
                    Debug.LogError("AssetPackUtil::AddAddressGroup->AssetAddressConfig is not found!");
                    return;
                }

                AssetPackerGroupData groupData = new AssetPackerGroupData()
                {
                    groupName = AddressGroupName,
                };
                AssetPackerAddressData addressData = new AssetPackerAddressData()
                {
                    assetAddress  = AssetConst.ASSET_ADDRESS_CONFIG_NAME,
                    assetPath     = assetPaths[0],
                    bundlePath    = AssetConst.ASSET_ADDRESS_BUNDLE_NAME,
                    bundlePathMd5 = MD5Crypto.Md5(AssetConst.ASSET_ADDRESS_BUNDLE_NAME).ToLower(),
                };
                groupData.assetFiles.Add(addressData);

                assetPackerConfig.groupDatas.Add(groupData);
            }
        }
Пример #4
0
        private bool FilterAddressData(AssetPackerAddressData addressData)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                return(true);
            }

            bool isValid = false;

            if (searchCategoryIndex == 0 || searchCategoryIndex == 1)
            {
                if (!string.IsNullOrEmpty(addressData.assetAddress))
                {
                    isValid = addressData.assetAddress.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0;
                }
            }
            if (!isValid)
            {
                if (searchCategoryIndex == 0 || searchCategoryIndex == 2)
                {
                    if (!string.IsNullOrEmpty(addressData.assetPath))
                    {
                        isValid = addressData.assetPath.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0;
                    }
                }
            }
            if (!isValid)
            {
                if (searchCategoryIndex == 0 || searchCategoryIndex == 3)
                {
                    if (!string.IsNullOrEmpty(addressData.bundlePath))
                    {
                        string bPath = $"{addressData.bundlePath} {addressData.bundlePathMd5}";
                        isValid = bPath.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0;
                    }
                }
            }
            if (!isValid)
            {
                string label = string.Join(",", addressData.labels);
                if (searchCategoryIndex == 0 || searchCategoryIndex == 4)
                {
                    if (!string.IsNullOrEmpty(label))
                    {
                        isValid = label.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0;
                    }
                }
            }
            return(isValid);
        }