| | |
| | | using System.Text;
|
| | | using Cysharp.Threading.Tasks;
|
| | | using YooAsset.Editor;
|
| | | using UnityEngine.AssetBundles;
|
| | |
|
| | | //using Beebyte.Obfuscator;
|
| | |
|
| | |
| | | }
|
| | | Debug.Log("[ClientPackage] YooAsset 资源打包完成。");
|
| | |
|
| | | // 打包成功后,将完整 StreamingAssets/yoo 拷贝到 Output Path(裁剪前执行,确保拿到全量资源)
|
| | | if (!string.IsNullOrEmpty(_assetBundlePath))
|
| | | {
|
| | | YooAssetBuildTool.CopyStreamingAssetsToOutputPath(_assetBundlePath);
|
| | | }
|
| | |
|
| | | // YooAsset StreamingAssets 根目录
|
| | | string yooRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
| | |
|
| | | // ---- NullAsset(小包):只保留 Launch 必需 Package,其它资源从 CDN 按需下载 ----
|
| | | // ---- NullAsset(小包):不随包携带 StreamingAssets 资源,全部从 CDN 按需下载 ----
|
| | | if (smallPackages.Count > 0)
|
| | | {
|
| | | RemovePackagesExcept(yooRoot, LaunchRequiredYooPackages);
|
| | | YooAssetBuildTool.ClearStreamingAssetsYooDirectory();
|
| | | Debug.Log("[ClientPackage] NullAsset: 已清空 StreamingAssets/yoo");
|
| | |
|
| | | // 写入随包 Package 列表,运行时 Builtin/Dll 创建 BuildinFileSystem,其它包走 CacheFileSystem
|
| | | // 写入随包 Package 列表,NullAsset 为空列表
|
| | | YooAssetBuildTool.WriteBuildinPackageList();
|
| | |
|
| | | for (int i = 0; i < smallPackages.Count; i++)
|
| | |
| | |
|
| | | public static void BuildApk(string _sdkPath, string _output, string _publisher, int _buildIndex, bool _development, string _streamingAssetsOutputPath = null)
|
| | | {
|
| | | YooAssetBuildTool.DeleteStartupConfigsFromStreamingAssets();
|
| | | PreBuild(_publisher, _buildIndex);
|
| | | var auditTimeFile = StringUtility.Concat(Application.dataPath, Path.DirectorySeparatorChar.ToString(), "Resources/Config/AuditTime.txt");
|
| | | if (File.Exists(auditTimeFile))
|
| | |
| | | AssetDatabase.SaveAssets();
|
| | | AssetDatabase.Refresh();
|
| | |
|
| | | if (_streamingAssetsOutputPath != null && !YooAssetBuildTool.CopyStreamingAssetsToOutputPath(_streamingAssetsOutputPath))
|
| | | {
|
| | | Debug.LogError("[ClientPackage] 拷贝 StreamingAssets 到资源输出目录失败,中止 APK 构建。TARGET=" + _streamingAssetsOutputPath);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 确保不以 Gradle 工程模式输出(HybridCLR StripAOT 步骤会临时置为 true,若未还原则会输出文件夹而非 APK)
|
| | | EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
|
| | |
|
| | |
| | | string copySdkFile;
|
| | | copySdkFile = StringUtility.Concat(SDK_PLUGIN_PROJECT, "/Channel/Android/", versionConfig.sdkFileName, "/AndroidManifest.xml");
|
| | | File.Copy(copySdkFile, MANIFEST_PATH);
|
| | | PreBuild(_publisher, _buildIndex);
|
| | |
|
| | |
|
| | | PlayerSettings.Android.bundleVersionCode = VersionConfig.GetVersionNumber(versionConfig.version);
|
| | | PlayerSettings.enableInternalProfiler = _development;
|
| | |
|
| | | //完整取StreamingAssets 资源
|
| | | |
| | | // // 先清理StreamingAssets,再根据assetAccess配置拷贝资源到StreamingAssets
|
| | | // var streamingPath = ResourcesPath.Instance.StreamingAssetPath;
|
| | | // if (Directory.Exists(streamingPath))
|
| | | // Directory.Delete(streamingPath, true);
|
| | |
|
| | | // if (!string.IsNullOrEmpty(_assetBundlePath) && Directory.Exists(_assetBundlePath))
|
| | | // {
|
| | | // switch (versionConfig.assetAccess)
|
| | | // {
|
| | | // case InstalledAsset.NullAsset:
|
| | | // CopyNullAssetResources(_assetBundlePath, streamingPath);
|
| | | // break;
|
| | | // case InstalledAsset.HalfAsset:
|
| | | // CopyHalfAssetResources(_assetBundlePath, streamingPath);
|
| | | // break;
|
| | | // case InstalledAsset.FullAsset:
|
| | | // case InstalledAsset.IngoreDownLoad:
|
| | | // CopyFullAssetResources(_assetBundlePath, streamingPath);
|
| | | // break;
|
| | | // }
|
| | | // Debug.LogFormat("资源拷贝完成({0}),从 {1} 到 {2}", versionConfig.assetAccess, _assetBundlePath, streamingPath);
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // Debug.LogWarningFormat("AssetBundle路径为空或不存在: {0},导出工程将不包含游戏资源", _assetBundlePath);
|
| | | // }
|
| | |
|
| | | if (_assetBundlePath != null && !YooAssetBuildTool.CopyStreamingAssetsToOutputPath(_assetBundlePath))
|
| | | if (!YooAssetBuildTool.BuildAllPackagesCore(incremental: false, _assetBundlePath))
|
| | | {
|
| | | Debug.LogError("[ClientPackage] 拷贝 StreamingAssets 到资源输出目录失败,中止 Android 工程导出。TARGET=" + _assetBundlePath);
|
| | | Debug.LogError("[ClientPackage] YooAsset 资源打包失败,中止 Android 工程导出。");
|
| | | return;
|
| | | }
|
| | |
|
| | | string yooRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
| | | switch (versionConfig.assetAccess)
|
| | | {
|
| | | case InstalledAsset.NullAsset:
|
| | | YooAssetBuildTool.ClearStreamingAssetsYooDirectory();
|
| | | Debug.Log("[ClientPackage] NullAsset Export: 已清空 StreamingAssets/yoo");
|
| | | break;
|
| | | case InstalledAsset.HalfAsset:
|
| | | var removePackages = new List<string> { "Battle", "Audio", "Video", "UIEffect" };
|
| | | if (!includeUI) removePackages.Add("UI");
|
| | | foreach (var pkgName in removePackages)
|
| | | {
|
| | | string pkgDir = Path.Combine(yooRoot, pkgName);
|
| | | if (Directory.Exists(pkgDir))
|
| | | {
|
| | | Directory.Delete(pkgDir, true);
|
| | | Debug.Log($"[ClientPackage] HalfAsset Export: 已剔除 Package '{pkgName}'");
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | |
|
| | | YooAssetBuildTool.WriteBuildinPackageList();
|
| | | YooAssetBuildTool.DeleteStartupConfigsFromStreamingAssets();
|
| | | PreBuild(_publisher, _buildIndex);
|
| | |
|
| | | // 关键设置:导出为Gradle工程而非直接打APK
|
| | | EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
|
| | |
| | |
|
| | | Debug.LogFormat("导出Android工程完成!输出路径: {0}", outputDir);
|
| | |
|
| | | // 恢复完整 StreamingAssets 供后续打包使用
|
| | | RestoreYooStreamingAssets();
|
| | |
|
| | | // 导出完成后恢复设置
|
| | | EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
|
| | | EditorUserBuildSettings.development = false;
|