首页 > 其他分享 >Unity安卓IOS一键打包

Unity安卓IOS一键打包

时间:2024-05-22 14:32:57浏览次数:20  
标签:string 安卓 IOS filename outputPath Unity buildTarget using Android

添加菜单构建按钮,使用下面API进行构建,注意设置和配置等

using System;
using System.IO;
using AssetBundles;
using LiXiaoQian.Common.Editor.Tools;
using UnityEditor;
using UnityEngine;

/// 打包工具
public class BuildTool
{
    [MenuItem("Tools/构建/Android平台")]
    public static void BuildAndroid()
    {
        var buildTarget = BuildTarget.Android;
        string rootPath = "Build";
        //string build = $"{DateTime.Now:yyMMddHHmmss}";
        string outputPath = Path.Combine(rootPath, Utility.GetPlatformForAssetBundles(buildTarget));
        string filename = outputPath + $"\\SunlightRock.apk";
        
        if (File.Exists(filename))
        {
            File.Delete(filename);
        }

        Directory.CreateDirectory(outputPath);
        EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
        PlayerSettings.Android.keystoreName = "Lixiaoqian.keystore";
        PlayerSettings.Android.keystorePass = "lxq123456";
        PlayerSettings.Android.keyaliasName = "lixiaoqian";
        PlayerSettings.Android.keyaliasPass = "lxq123456";
        SetVersionMode.SetBuildVersion();
        BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, filename, buildTarget, BuildOptions.None);
        Debug.Log(buildTarget + "平台构建完成.  文件位于" + filename);
    }

    [MenuItem("Tools/构建/iOS平台")]
    public static void BuildiOS()
    {
        var buildTarget = BuildTarget.iOS;
        string rootPath = "Build";
        //string build = $"{DateTime.Now:yyMMddHHmmss}";
        string outputPath = Path.Combine(rootPath, Utility.GetPlatformForAssetBundles(buildTarget));

        if (Directory.Exists(outputPath))
        {
            Directory.Delete(outputPath, true);
        }

        Directory.CreateDirectory(outputPath);
        SetVersionMode.SetBuildVersion();
        BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, outputPath, buildTarget, BuildOptions.None);
        Debug.Log(buildTarget + "平台构建完成.  文件位于" + outputPath);
    }
}

 

标签:string,安卓,IOS,filename,outputPath,Unity,buildTarget,using,Android
From: https://www.cnblogs.com/weigangblog/p/18206156

相关文章

  • Unity控制物体有放缩弹一弹的效果
     usingUnityEngine;usingSystem.Collections;//控制有放缩弹一弹的效果publicclassScaleController:MonoBehaviour{boolismax=false;publicfloatscaleSpeed=0.003f;//可调速度publicfloatscalemax=2,scalemin=1.5f;//可调范......
  • 【unity】在EditorWindow添加自定义的Toolbar按钮
    好久没写了,最近做工具,写了个EditorWindow,为了让使用者方便查看这个工具的文档,想着在导航栏加个问号按钮,点一下打开说明文档就完事~查了下unity手册,发现Unity提供了一个ShowButton 方法,用于在自定义Editor窗口的工具栏中添加自定义内容,下面是实现的例子:privateGUIStyle......
  • Unity制作一个协程管理工具
    IEnumeratorToolusingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassIEnumeratorTool:MonoBehaviour{///<summary>///压入的action任务///</summary>publicclassActionTask......
  • 高德地图安卓sdk,在uniapp中实现,地图上多个坐标点,点击坐标点,显示坐标信息
     <template><viewclass="content"><mapid="map":style="{width:'100%',height:'50vh'}":markers="markers":longitude="longitude":latitude=......
  • Unity设置UI和Render的渲染层级
    通过给UI或物体挂载下面脚本,来设置层级usingUnityEngine;usingSystem.Collections;usingUnityEngine.UI;namespaceCommon{//设置UI和render的层级publicclassUIDepth:MonoBehaviour{publicintorder;publicboolisUI=true;......
  • uniapp-vue3-oadmin手机后台实例|vite5.x+uniapp多端仿ios管理系统
    原创vue3+uniapp+uni-ui跨端仿ios桌面后台OA管理模板Uni-Vue3-WeOS。uniapp-vue3-os一款基于uni-app+vite5.x+pinia等技术开发的仿ios手机桌面OA管理系统。实现了自定义桌面栅格磁贴布局、多分屏滑动管理、自定义桌面小部件、辅助触控悬浮球等功能。支持编译到H5+小程序端+App端......
  • Unity性能优化:什么是内存泄露?
    内存泄漏是优化方面的名词,主要是由于不再使用的资源没有及时清理,来释放内存,造成内存的浪费,造成系统卡顿。 或者说,内存就像花呗,额度就这么多,有借要有还,而且手里有闲钱的时候就记得还,以保证内存的充足,如果占着不用,就会在其他需要使用的时候内存不足,就容易崩溃出现问题。 Unity......
  • Unity制作一个定时器Timer
    Timer和TimerManager代码usingSystem.Collections;usingUnityEngine;publicclassTimer:MonoBehaviour{publicdelegatevoidNotifier();publicNotifieronTimer;publicNotifieronTimerReset;publicNotifieronTimerComplete;publicfl......
  • Unity制作一个BroadcastUI 跑马灯文字广播
     usingDG.Tweening;usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.UI;usingUtils;//挂在UI上面publicclassBroadcastUI:MonoBehaviour{privateboolinited=false;privateBroadcastManbm;......
  • Unity查找物体和组件的方法
    一、找物体:①GameObject:a).Find(stringname)通过物体的名字查找b).FindWithTag(stringtag);通过标签获取添加该标签的一个物体c).FindObjectOfType();依据组件类型d).FindGameObjectsWithTag(stringtag)通过标签获取所有添加该标签的物体数组返回一个组合 ②Transform......