转 代码修改buildoption
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
public class BuildPlayer : ScriptableObject
{
static string rootPath = Application.dataPath + Path.DirectorySeparatorChar;
static string rootParent = new DirectoryInfo(rootPath).Parent.FullName + Path.DirectorySeparatorChar;
static string projectName = new DirectoryInfo(rootPath).Parent.Name;
static string scenePath = Application.dataPath + Path.DirectorySeparatorChar + "Scenes" + Path.DirectorySeparatorChar;
static string apkNameDebug = rootParent + projectName + "_Debug_[Date].apk";
static string apkNameRelease = rootParent + projectName + "_Release_[Date].apk";
[MenuItem("Build Player/Build Android Debug", false, 101)]
static void BuildAndroidDebug()
{
AssetDatabase.Refresh();
// set build options and build player
BuildOptions options = BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ShowBuiltPlayer;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameDebug), BuildTarget.Android, options);
}
[MenuItem("Build Player/Build Android Debug(Auto Deploy)", false, 102)]
static void BuildAndroidDebugAutoDeploy()
{
AssetDatabase.Refresh();
// set build options and build player
BuildOptions options = BuildOptions.Development | BuildOptions.AutoRunPlayer | BuildOptions.AllowDebugging;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameDebug), BuildTarget.Android, options);
}
[MenuItem("Build Player/Build Android Debug(Auto Deploy And Connect Profiler)", false, 103)]
static void BuildAndroidDebugAutoDeployAndConnectProfiler()
{
AssetDatabase.Refresh();
// set build options and build player
BuildOptions options = BuildOptions.Development | BuildOptions.AutoRunPlayer | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameDebug), BuildTarget.Android, options);
}
[MenuItem("Build Player/Build Android Release", false, 201)]
static void BuildAndroidRelease()
{
// rename all debug scripts to *.rem
RenameDebugScripts();
// set build options and build player
BuildOptions options = BuildOptions.ShowBuiltPlayer;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameRelease), BuildTarget.Android, options);
// restore all debug scripts' file names
RestoreDebugScripts();
}
[MenuItem("Build Player/Build Android Release(Auto Deploy)", false, 202)]
static void BuildAndroidReleaseAutoDeploy()
{
// rename all debug scripts to *.rem
RenameDebugScripts();
// set build options and build player
BuildOptions options = BuildOptions.AutoRunPlayer;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameRelease), BuildTarget.Android, options);
// restore all debug scripts' file names
RestoreDebugScripts();
}
static void RenameDebugScripts()
{
string[] allDebugDirectories = Directory.GetDirectories(rootPath, "_Debug", SearchOption.AllDirectories);
foreach (string directory in allDebugDirectories)
{
string[] scripts = Directory.GetFiles(directory, "*.cs", SearchOption.AllDirectories);
foreach (string script in scripts)
{
string newScriptName = script + ".rem";
File.Move(script, newScriptName);
File.Delete(script + ".meta");
}
}
AssetDatabase.Refresh();
}
static void RestoreDebugScripts()
{
string[] allDebugDirectories = Directory.GetDirectories(rootPath, "_Debug", SearchOption.AllDirectories);
foreach (string directory in allDebugDirectories)
{
string[] renamedScripts = Directory.GetFiles(directory, "*.rem", SearchOption.AllDirectories);
foreach (string renamedScript in renamedScripts)
{
string scriptName = renamedScript.Substring(0, renamedScript.Length - 3);
File.Move(renamedScript, scriptName);
File.Delete(renamedScript + ".meta");
}
}
AssetDatabase.Refresh();
}
static string[] GetAllScenes()
{
string[] allScenes = null;
DirectoryInfo dirInfo = new DirectoryInfo(scenePath);
FileInfo[] fileInfos = dirInfo.GetFiles("*.unity", SearchOption.AllDirectories);
allScenes = new string[fileInfos.Length];
int index = 0;
foreach (FileInfo fileInfo in fileInfos)
{
string scene = fileInfo.FullName.Replace(rootParent, "");
allScenes[index++] = scene;
}
return allScenes;
}
static string InsertDateString(string apkName)
{
DateTime now = DateTime.Now;
return apkName.Replace("[Date]", string.Format("[{0:d4}{1:d2}{2:d2}][{3:d2}{4:d2}{5:d2}]", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second));
}
}
转 代码修改buildoption的更多相关文章
- Android之vector代码修改颜色
前言:google给了很多material design icon,在开发过程中,可以下载下来直接使用,下载地址为https://materialdesignicons.com/ . 1.下载图标,并 ...
- Asp.net使用代码修改配置文件的节点值
使用代码修改配置文件的方法: 1.打开配置文件写入的权限 2.先按节点名称长到要修改的节点,然后删除,紧接着将有新值的节点添加回去 3.关闭配置文件写入的权限 修改Appsetting节点的值,修改其 ...
- am335x UART1输入u-boot 调试信息代码修改
AM335x 调试信息UART1输出代码修改1. 关于pin_mux 的配置代码修改位置:/board/forlinx/ok335x/mux.c void enable_uart0_pin_mux( ...
- SharePoint开发 - 使用Session(代码修改webconfig)
博客地址 http://blog.csdn.net/foxdave SharePoint启用Session可以使用Powershell,戳这里:可以修改webconfig. 本篇叙述的重点是通过fea ...
- Spring+SpringMVC+MyBatis整合进阶篇(四)RESTful实战(前端代码修改)
前言 前文<RESTful API实战笔记(接口设计及Java后端实现)>中介绍了RESTful中后端开发的实现,主要是接口地址修改和返回数据的格式及规范的修改,本文则简单介绍一下,RES ...
- 在win7上跑基于任少卿作者代码修改的RPN+BF实验
1.前言 之前在win10上成功的跑起来faster-rcnn的实验,并且跑了一下CaltechPedestrian的数据集,但是效果一直不理想,折腾了好久也没弄清楚到底原因出在哪里,直到读了Is F ...
- u-boot移植(十二)---代码修改---支持DM9000网卡
一.准备工作 1.1 原理图 CONFIG_DM9000_BASE 片选信号是接在nGCS4引脚,若要确定网卡的基地址,则要根据片选信号的接口去确定. 在三星2440的DATASHEET中memory ...
- 开始玩qt,使用代码修改设计模式生成的菜单
之前制作菜单时,不是纯代码便是用设计模式 直接图形化完成. 今天我就是想用代码修改已经存在的菜单项,如果是用代码生成的可以直接调用指针完成: 但通过设计模式完成的没有暴露指针给我,至少我没发现. 在几 ...
- master-worker常驻型程序代码修改哪些需要重启master或者worker
之前在yii的项目里用redis作为消息队列,现在很多任务需要延迟需求,于是把之前redis的消息队列替换成了rabbitmq 于是使用yii的yii2-queue这个组件 但是由于提供的yii qu ...
随机推荐
- scrapy_novel_python
# _*_ coding:UTF _8_ from bs4 import BeautifulSoup import requests,sys class downloader(object): def ...
- ubuntu 18.04下安装配置HBase问题记录
参考资料: Ubuntu下HBase安装与使用(shell+Java API) 问题 无法正常启动hbase,在Log里报错java.lang.ClassNotFoundException: org. ...
- MD5加密算法Java代码实现
package com.app.utils; import java.math.BigInteger; import java.security.MessageDigest; import java. ...
- URL的解析,C语言实现
源: URL的解析,C语言实现 c语言实现urlencode和decode
- mycat高可用集群搭建
本文来源于:https://blog.csdn.net/u012758088/article/details/78741567 Mycat 本身是无状态的,可以用 HAProxy 或四层交换机等设备组 ...
- Golang字符串格式化
Go对字符串格式化提供了良好的支持.下面我们看些常用的字符串格式化的例子. package main import ( "fmt" "os" ) type po ...
- css基本知识、选择器
CSS 是指层叠样式表 (Cascading Style Sheets),基本语法规则如下 CSS 由两个主要的部分构成:选择器,以及一条或多条声明 声明以大括号{ }括起来,一个申明包括属性和值,属 ...
- Python学习基础(二)——集合 深浅拷贝 函数
集合 # 集合 ''' 集合是无序不重复的 ''' # 创建列表 l = list((1, 1, 1)) l1 = [1, 1, 1] print(l) print(l1) print("* ...
- linux日常管理
1.压缩和解压 tar压缩tar -czf hxl_product.tar.gz ./product tar解压tar -xzvf hxl_app.tar.gz z选项会将该压缩文件直接解压到目录,要 ...
- topcoder srm 535 div1
problem1 link 对于每个质因子$p$,枚举其出现的最少次数以及最多次数分别在哪个数字中. problem2 link 分数规划.题目是求$\frac{3600K+\sum_{i=0}^{K ...