• Unity命令行打包


    http://www.66acg.com/?post=137


    补充

    unity编辑器端获取打包命令行自定义参数,这个可以获取到所有打包时的参数

    string[] runArgs = System.Environment.GetCommandLineArgs();




    一、在AssetsEditor目录下放个脚本

    using UnityEngine;
    using UnityEditor;
    using System;
    using System.IO;
    using System.Collections.Generic;
     
    /// <summary>
    /// 命令行批处理工具类
    /// </summary>
    public class Batchmode {
     
        static List<string> levels = new List<string>();
        static string keystoreFile = @"D:keystore.txt";
     
        public static void BuildAndroid() {
            
     
            if(!File.Exists(keystoreFile))
                throw new Exception("Not find keystore file");
     
            StreamReader sr = File.OpenText(keystoreFile);
            string password = sr.ReadToEnd().Trim();
     
            PlayerSettings.Android.keystorePass = password;
            PlayerSettings.Android.keyaliasPass = password;
     
            foreach ( EditorBuildSettingsScene scene in EditorBuildSettings.scenes ) {
                if ( !scene.enabled ) continue;
                levels.Add( scene.path );
            }
    		EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
            string res = BuildPipeline.BuildPlayer( levels.ToArray(), "android.apk", BuildTarget.Android, BuildOptions.None );
            if (res.Length > 0)
                throw new Exception("BuildPlayer failure: " + res);
        }
    }

    二、写个批处理(路径改成自己的工程路径)

    @echo off
    @set unity="C:Program FilesUnityEditorUnity.exe"
    echo 正在生成APK文件...
    %unity%  -batchmode -quit -nographics -executeMethod Batchmode.BuildAndroid  -logFile D:Editor.log -projectPath "D:China2014-11-12_client_wushen_android" 
    echo APK文件生成完毕!
    pause



  • 相关阅读:
    jQuery弹出层插件大全:
    JavaScript数组去重的几种方法
    sql去除重复列(行)
    VS无法启动调试
    .将DayOfWeek转换成中文的几种方式
    关于 uniqueidentifier
    链接服务器
    我的目标:系统架构师
    异常(1)
    Visual C++开发工具与调试技巧整理
  • 原文地址:https://www.cnblogs.com/nafio/p/9137244.html
Copyright © 2020-2023  润新知