Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        public static AssetPackerConfig GetAssetPackerConfig()
        {
            AssetPackerConfig packerConfig = new AssetPackerConfig();

            AssetAddressGroup[] groups = AssetDatabaseUtility.FindInstances <AssetAddressGroup>();
            if (groups != null && groups.Length > 0)
            {
                foreach (var group in groups)
                {
                    AssetPackerGroupData groupData = new AssetPackerGroupData();
                    groupData.groupName      = group.groupName;
                    groupData.isMain         = group.isMain;
                    groupData.isPreload      = group.isPreload;
                    groupData.isNeverDestroy = group.isNeverDestroy;

                    groupData.assetFiles = GetAssetsInGroup(group);

                    packerConfig.groupDatas.Add(groupData);
                }
            }
            packerConfig.Sort();

            AddAddressGroup(packerConfig);

            return(packerConfig);
        }
Ejemplo n.º 3
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);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public bool IsGroupAddressRepeated(AssetPackerGroupData group)
 {
     foreach (var data in group.assetFiles)
     {
         if (IsAddressRepeated(data.assetAddress, out List <AssetPackerAddressData> list))
         {
             return(true);
         }
     }
     return(false);
 }