Exemple #1
0
        public static AssetPackConfig Deserialize(SerializableAssetPackConfig config)
        {
            var assetPackConfig = new AssetPackConfig
            {
                DefaultTextureCompressionFormat = config.DefaultTextureCompressionFormat
            };

            foreach (var multiTargetingAssetBundle in config.assetBundles)
            {
                var assetBundles = multiTargetingAssetBundle.assetBundles;
                if (assetBundles.Count == 0)
                {
                    continue;
                }

                // TODO: consider checking the folder name for "#tcf".
                if (assetBundles.Count == 1 &&
                    assetBundles[0].TextureCompressionFormat == TextureCompressionFormat.Default)
                {
                    assetPackConfig.AddAssetBundle(assetBundles[0].path, multiTargetingAssetBundle.DeliveryMode);
                    continue;
                }

                var dictionary = assetBundles.ToDictionary(item => item.TextureCompressionFormat, item => item.path);
                assetPackConfig.AddAssetBundles(dictionary, multiTargetingAssetBundle.DeliveryMode);
            }

            foreach (var pack in config.assetPacks)
            {
                assetPackConfig.AddAssetsFolder(pack.name, pack.path, pack.DeliveryMode);
            }

            return(assetPackConfig);
        }
Exemple #2
0
        /// <summary>
        /// Creates an AssetPackConfig from the specified SerializableAssetPackConfig, validating its fields
        /// in the process. Note: AssetBundle names are interpreted from the AssetBundle path rather than
        /// the specified names.
        /// </summary>
        public static AssetPackConfig Deserialize(SerializableAssetPackConfig config)
        {
            var assetPackConfig = new AssetPackConfig
            {
                DefaultTextureCompressionFormat = config.DefaultTextureCompressionFormat,
                SplitBaseModuleAssets           = config.splitBaseModuleAssets
            };

            foreach (var multiTargetingAssetBundle in config.assetBundles)
            {
                var assetBundles = multiTargetingAssetBundle.assetBundles;
                if (assetBundles.Count == 0)
                {
                    continue;
                }

                // TODO: consider checking the folder name for "#tcf".
                if (assetBundles.Count == 1 &&
                    assetBundles[0].TextureCompressionFormat == TextureCompressionFormat.Default
                    )
                {
                    assetPackConfig.AddAssetBundle(assetBundles[0].path, multiTargetingAssetBundle.DeliveryMode);
                    continue;
                }

                var dictionaryTextureCompression =
                    assetBundles
                    .ToDictionary(item => item.TextureCompressionFormat, item => item.path);
                if (dictionaryTextureCompression.Count != 0)
                {
                    assetPackConfig.AddAssetBundles(dictionaryTextureCompression,
                                                    multiTargetingAssetBundle.DeliveryMode);
                }
            }

            foreach (var pack in config.assetPacks)
            {
                assetPackConfig.AddAssetsFolder(pack.name, pack.path, pack.DeliveryMode);
            }

            foreach (var pack in config.targetedAssetPacks)
            {
                var compressionFormatToAssetPackDirectoryPath =
                    pack.paths
                    .ToDictionary(item => item.TextureCompressionFormat, item => item.path);
                if (compressionFormatToAssetPackDirectoryPath.Count != 0)
                {
                    assetPackConfig.AddAssetsFolders(
                        pack.name, compressionFormatToAssetPackDirectoryPath, pack.DeliveryMode);
                }
            }

            return(assetPackConfig);
        }