void CreateOrEditGradleFile(string androidPackDir, string assetPackName, DeliveryType deliveryType) { if (deliveryType == DeliveryType.None) { Addressables.Log($"Asset pack '{assetPackName}' has its delivery type set to 'None'. " + $"No gradle file will be created for this asset pack. Unity assumes that any custom asset packs with no gradle file use on-demand delivery."); return; } // Warn about other gradle files in the .androidpack directory List <string> gradleFiles = Directory.EnumerateFiles(androidPackDir, "*.gradle").Where(x => Path.GetFileName(x) != "build.gradle").ToList(); if (gradleFiles.Count > 0) { Addressables.LogWarning($"Custom asset pack at '{androidPackDir}' contains {gradleFiles.Count} files with .gradle extension which will be ignored. " + $"Only the 'build.gradle' file will be included in the Android App Bundle."); } // Create or edit the 'build.gradle' file in the .androidpack directory string deliveryTypeString = CustomAssetPackUtility.DeliveryTypeToGradleString(deliveryType); string buildFilePath = Path.Combine(androidPackDir, "build.gradle"); string content = $"apply plugin: 'com.android.asset-pack'\n\nassetPack {{\n\tpackName = \"{assetPackName}\"\n\tdynamicDelivery {{\n\t\tdeliveryType = \"{deliveryTypeString}\"\n\t}}\n}}"; File.WriteAllText(buildFilePath, content); }
void ClearJsonFiles() { // Delete "CustomAssetPacksData.json" if (File.Exists(CustomAssetPackUtility.CustomAssetPacksDataEditorPath)) { AssetDatabase.DeleteAsset(CustomAssetPackUtility.CustomAssetPacksDataEditorPath); } if (File.Exists(CustomAssetPackUtility.CustomAssetPacksDataRuntimePath)) { File.Delete(CustomAssetPackUtility.CustomAssetPacksDataRuntimePath); File.Delete(CustomAssetPackUtility.CustomAssetPacksDataRuntimePath + ".meta"); CustomAssetPackUtility.DeleteDirectory(Application.streamingAssetsPath, true); } // Delete "BuildProcessorData.json" if (File.Exists(CustomAssetPackUtility.BuildProcessorDataPath)) { AssetDatabase.DeleteAsset(CustomAssetPackUtility.BuildProcessorDataPath); } }