static void PackAndroidApp() { Debug.LogError("android package ----- 1"); var start = DateTime.Now; Debug.LogError("android package ----- 2"); BuildTarget buildTarget = BuildTarget.Android; ChannelType channelType = ChannelType.Test; Debug.LogError("android package ----- 3"); AssetBundleDispatcherInspector.hasAnythingModified = true; BuildPlayer.BuildAssetBundles(buildTarget, channelType.ToString()); AssetBundleDispatcherInspector.hasAnythingModified = false; Debug.LogError("android package ----- 4"); AssetBundleMenuItems.ToolsCopyAssetbundlesAndScripts(); Debug.LogError("android package ----- 5"); PackageTool.BuildAndroidPlayerForCurrentChannel(); Debug.LogError("android package ----- 6"); var folder = PackageUtils.GetChannelOutputPath(buildTarget, channelType.ToString()); EditorUtils.ExplorerFolder(folder); Debug.LogError("android package ----- 7"); Debug.LogError($"Android Package Success!!! Use Time {(DateTime.Now - start).TotalSeconds}"); }
void DrawBuildAndroidPlayerGUI() { GUILayout.Space(3); GUILayout.Label("-------------[Build Android Player]-------------"); GUILayout.Space(3); GUILayout.BeginHorizontal(); if (PackageUtils.BuildAssetBundlesForPerChannel(buildTarget)) { if (GUILayout.Button("Copy SDK Resources", GUILayout.Width(200))) { EditorApplication.delayCall += CopyAndroidSDKResources; } if (GUILayout.Button("Current Channel Only", GUILayout.Width(200))) { EditorApplication.delayCall += BuildAndroidPlayerForCurrentChannel; } if (GUILayout.Button("For All Channels", GUILayout.Width(200))) { EditorApplication.delayCall += BuildAndroidPlayerForAllChannels; } if (GUILayout.Button("Open Output Folder", GUILayout.Width(200))) { var folder = PackageUtils.GetChannelOutputPath(buildTarget, channelType.ToString()); EditorUtils.ExplorerFolder(folder); } } else { if (GUILayout.Button("Copy SDK Resource", GUILayout.Width(200))) { EditorApplication.delayCall += CopyAndroidSDKResources; } if (GUILayout.Button("Execute Build", GUILayout.Width(200))) { EditorApplication.delayCall += BuildAndroidPlayerForCurrentChannel; } if (GUILayout.Button("Open Output Folder", GUILayout.Width(200))) { var folder = PackageUtils.GetChannelOutputPath(buildTarget, channelType.ToString()); EditorUtils.ExplorerFolder(folder); } } GUILayout.EndHorizontal(); }
public static void BuildAndroid(string channelName, bool isTest) { BuildTarget buildTarget = BuildTarget.Android; PackageUtils.CopyAssetBundlesToStreamingAssets(buildTarget, channelName); if (!isTest) { LaunchAssetBundleServer.ClearAssetBundleServerURL(); } else { LaunchAssetBundleServer.WriteAssetBundleServerURL(); } BaseChannel channel = ChannelManager.instance.CreateChannel(channelName); SetPlayerSetting(channel); string savePath = PackageUtils.GetChannelOutputPath(buildTarget, channelName); string appName = channel.GetProductName() + ".apk"; if (channel.IsGooglePlay()) { savePath = Path.Combine(savePath, "GooglePlay"); UtilityGame.SafeDeleteDir(savePath); BuildPipeline.BuildPlayer(GetBuildScenes(), savePath, buildTarget, BuildOptions.AcceptExternalModificationsToPlayer); } else { savePath = Path.Combine(savePath, appName); BuildPipeline.BuildPlayer(GetBuildScenes(), savePath, buildTarget, BuildOptions.None); } string outputPath = Path.Combine(Application.persistentDataPath, AssetBundleConfig.AssetBundlesFolderName); UtilityGame.SafeDeleteDir(outputPath); Debug.Log(string.Format("Build android player for : {0} done! output :{1}", channelName, savePath)); }
void DrawAssetBundlesGUI() { GUILayout.Space(3); GUILayout.Label("-------------[Build AssetBundles]-------------"); GUILayout.BeginHorizontal(); // if (buildTarget == BuildTarget.Android) // { // GUILayout.Label("Android Lua打包成Ab : ", GUILayout.Width(150)); // AssetBundleConfig.IsPackLuaAb = EditorGUILayout.Toggle(AssetBundleConfig.IsPackLuaAb, GUILayout.Width(50)); // } GUILayout.EndHorizontal(); GUILayout.Space(3); GUILayout.Space(3); GUILayout.BeginHorizontal(); if (buildABSForPerChannel) { if (GUILayout.Button("Current Channel Only", GUILayout.Width(200))) { EditorApplication.delayCall += BuildAssetBundlesForCurrentChannel; } if (GUILayout.Button("For All Channels", GUILayout.Width(200))) { EditorApplication.delayCall += BuildAssetBundlesForAllChannels; } if (GUILayout.Button("Open Current Output", GUILayout.Width(200))) { AssetBundleMenuItems.ToolsOpenOutput(); } if (GUILayout.Button("Copy To StreamingAsset", GUILayout.Width(200))) { AssetBundleMenuItems.ToolsCopyAssetbundles(); AssetDatabase.Refresh(); } } else { if (GUILayout.Button("打包ab包并拷贝", GUILayout.Width(200))) { var start = DateTime.Now; EditorApplication.delayCall += BuildAssetBundlesForCurrentChannel; EditorApplication.delayCall += () => { AssetBundleMenuItems.ToolsCopyAssetbundles(); AssetDatabase.Refresh(); }; EditorApplication.delayCall += () => { EditorUtility.DisplayDialog("打包完成", $"RunAllCheckres; ExecuteBuild; CopyToStreamingAsset; 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm"); }; } if (GUILayout.Button("打开ab包目录", GUILayout.Width(200))) { AssetBundleMenuItems.ToolsOpenOutput(); } if (GUILayout.Button("生成引用计数大于1的资源目录", GUILayout.Width(200))) { EditorApplication.delayCall += () => { CheckAllDependenciesRes(); }; EditorApplication.delayCall += () => { CMDController.ExcuteCmdFile(CMDController.CMDHotUpdateFile); }; } } GUILayout.EndHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("拷贝Lua的代码", GUILayout.Width(200))) { var start = DateTime.Now; AssetBundleMenuItems.ToolsCopyLuaScriptsToAssetbundles(); AssetDatabase.Refresh(); EditorApplication.delayCall += () => { EditorUtility.DisplayDialog("拷贝Lua代码完成", $" 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm"); }; } EditorGUILayout.Space(); if (GUILayout.Button("打包拷贝ab&拷贝lua", GUILayout.Width(200))) { var start = DateTime.Now; EditorApplication.delayCall += () => { AssetBundleDispatcherInspector.hasAnythingModified = true; BuildPlayer.BuildAssetBundles(buildTarget, channelType.ToString()); AssetBundleDispatcherInspector.hasAnythingModified = false; }; EditorApplication.delayCall += () => { CMDController.ExcuteCmdFile(); }; EditorApplication.delayCall += () => { AssetBundleMenuItems.ToolsCopyAssetbundlesAndScripts(); }; EditorApplication.delayCall += () => { EditorUtility.DisplayDialog("一键完成", $"RunAllCheckres; ExecuteBuild; CopyToStreamingAsset; Copy LuaSciptsToStreamingAsset; 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm"); }; } EditorGUILayout.Space(); if (GUILayout.Button("一键+打包", GUILayout.Width(200))) { var start = DateTime.Now; EditorApplication.delayCall += () => { AssetBundleDispatcherInspector.hasAnythingModified = true; BuildPlayer.BuildAssetBundles(buildTarget, channelType.ToString()); AssetBundleDispatcherInspector.hasAnythingModified = false; }; EditorApplication.delayCall += () => { AssetBundleMenuItems.ToolsCopyAssetbundlesAndScripts(); }; EditorApplication.delayCall += CheckAllDependenciesRes; EditorApplication.delayCall += BuildAndroidPlayerForCurrentChannel; EditorApplication.delayCall += () => { CMDController.ExcuteCmdFile(CMDController.CMDHotUpdateFile); }; EditorApplication.delayCall += () => { var folder = PackageUtils.GetChannelOutputPath(buildTarget, channelType.ToString()); EditorUtils.ExplorerFolder(folder); }; EditorApplication.delayCall += () => { EditorUtility.DisplayDialog("一键完成", $"RunAllCheckres; ExecuteBuild; CopyToStreamingAsset; Copy LuaSciptsToStreamingAsset; 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm"); }; } EditorGUILayout.Space(); if (GUILayout.Button("准备热更新资源", GUILayout.Width(200))) { CMDController.ExcuteCmdFile(CMDController.CMDHotUpdateFile); } GUILayout.Space(3); }