/// <summary> /// The processing of the bundled asset schema. This is where the bundle(s) for a given group are actually setup. /// </summary> /// <param name="schema">The BundledAssetGroupSchema to process</param> /// <param name="assetGroup">The group this schema was pulled from</param> /// <param name="aaContext">The general Addressables build builderInput</param> /// <returns>The error string, if any.</returns> protected virtual string ProcessBundledAssetSchema( BundledAssetGroupSchema schema, AddressableAssetGroup assetGroup, AddressableAssetsBuildContext aaContext) { if (schema == null || !schema.IncludeInBuild || !assetGroup.entries.Any()) { return(string.Empty); } var errorStr = ErrorCheckBundleSettings(schema, assetGroup, aaContext.settings); if (!string.IsNullOrEmpty(errorStr)) { return(errorStr); } var bundledProviderId = schema.GetBundleCachedProviderId(); var assetProviderId = schema.GetAssetCachedProviderId(); if (!m_CreatedProviderIds.Contains(bundledProviderId)) { m_CreatedProviderIds.Add(bundledProviderId); var bundleProviderType = schema.AssetBundleProviderType.Value; var bundleProviderData = ObjectInitializationData.CreateSerializedInitializationData(bundleProviderType, bundledProviderId); m_ResourceProviderData.Add(bundleProviderData); } if (!m_CreatedProviderIds.Contains(assetProviderId)) { m_CreatedProviderIds.Add(assetProviderId); var assetProviderType = schema.BundledAssetProviderType.Value; var assetProviderData = ObjectInitializationData.CreateSerializedInitializationData(assetProviderType, assetProviderId); m_ResourceProviderData.Add(assetProviderData); } var bundleInputDefs = new List <AssetBundleBuild>(); PrepGroupBundlePacking(assetGroup, bundleInputDefs, schema.BundleMode); HandleDuplicateBundleNames(bundleInputDefs, aaContext.bundleToAssetGroup, assetGroup.Guid, out var uniqueNames); m_OutputAssetBundleNames.AddRange(uniqueNames); m_AllBundleInputDefs.AddRange(bundleInputDefs); return(string.Empty); }
/// <summary> /// The processing of the bundled asset schema. This is where the bundle(s) for a given group are actually setup. /// </summary> /// <param name="schema">The BundledAssetGroupSchema to process</param> /// <param name="assetGroup">The group this schema was pulled from</param> /// <param name="aaContext">The general Addressables build builderInput</param> /// <returns>The error string, if any.</returns> protected virtual string ProcessBundledAssetSchema( BundledAssetGroupSchema schema, AddressableAssetGroup assetGroup, AddressableAssetsBuildContext aaContext) { if (schema == null || !schema.IncludeInBuild) { return(string.Empty); } var errorStr = ErrorCheckBundleSettings(schema, assetGroup, aaContext.settings); if (!string.IsNullOrEmpty(errorStr)) { return(errorStr); } var bundledProviderId = schema.GetBundleCachedProviderId(); var assetProviderId = schema.GetAssetCachedProviderId(); if (!m_CreatedProviderIds.Contains(bundledProviderId)) { m_CreatedProviderIds.Add(bundledProviderId); var bundleProviderType = schema.AssetBundleProviderType.Value; var bundleProviderData = ObjectInitializationData.CreateSerializedInitializationData(bundleProviderType, bundledProviderId); m_ResourceProviderData.Add(bundleProviderData); } if (!m_CreatedProviderIds.Contains(assetProviderId)) { m_CreatedProviderIds.Add(assetProviderId); var assetProviderType = schema.BundledAssetProviderType.Value; var assetProviderData = ObjectInitializationData.CreateSerializedInitializationData(assetProviderType, assetProviderId); m_ResourceProviderData.Add(assetProviderData); } var bundleInputDefs = new List <AssetBundleBuild>(); PrepGroupBundlePacking(assetGroup, bundleInputDefs, schema.BundleMode); for (int i = 0; i < bundleInputDefs.Count; i++) { if (aaContext.bundleToAssetGroup.ContainsKey(bundleInputDefs[i].assetBundleName)) { var bid = bundleInputDefs[i]; int count = 1; var newName = bid.assetBundleName; while (aaContext.bundleToAssetGroup.ContainsKey(newName) && count < 1000) { newName = bid.assetBundleName.Replace(".bundle", string.Format("{0}.bundle", count++)); } bundleInputDefs[i] = new AssetBundleBuild { assetBundleName = newName, addressableNames = bid.addressableNames, assetBundleVariant = bid.assetBundleVariant, assetNames = bid.assetNames }; } aaContext.bundleToAssetGroup.Add(bundleInputDefs[i].assetBundleName, assetGroup.Guid); } m_AllBundleInputDefs.AddRange(bundleInputDefs); return(string.Empty); }