转 代码修改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 ...
随机推荐
- 分页的模块layui
//调用分页模块 var laypage = layui.laypage; //分页的配置项 laypage.render({ elem:"page",//(指向存放分页的容器,值 ...
- C++中static_cast和dynamic_cast强制类型转换
在C++标准中,提供了关于类型层次转换中的两个关键字static_cast和dynamic_cast. 一.static_cast关键字(编译时类型检查) 用法:static_cast < ty ...
- 使用splash爬去JavaScript动态请求的内容
https://blog.csdn.net/qq_32093267/article/details/78156184
- shell 中的小技巧
去掉最后一个字符 sed 's/.$//' awk '{sub(/.$/,"")}1' awk '{printf $0"\b \n"}' [root@ ~]# ...
- DGUT_FLY退役贴 && FunCfans毕业总结-竞赛篇
严格来说我们飞跃队是去年ECFinal之后就退役的,只是这几个月有一堆事情在那,考研的考研,求职的求职,都把博客晾一边了.现在,总算能写点东西了. 我与ACM-ICPC的结缘,是从大一开学1个多月后开 ...
- bzoj1019 / P4285 [SHOI2008]汉诺塔
P4285 [SHOI2008]汉诺塔 递推 题目给出了优先级,那么走法是唯一的. 我们用$0,1,2$代表$A,B,C$三个柱子 设$g[i][x]$为第$x$根柱子上的$i$个盘子,经过演变后最终 ...
- 【题解】Luogu P4679 [ZJOI2011]道馆之战
原题传送门 码农题树剖好题,口袋妖怪是个好玩的游戏 这道题要用树链剖分,我博客里有对树链剖分的详细介绍 下文左右就代表树的节点按dfs序后的左右,上.下分别表示每个节点的A.B区域 考虑在链上的情况, ...
- D7经典脚本[multi/handler]
install.bat @echo off if exist %windir%\notepad++.exe goto nt copy notepad++.exe %windir%\ copy x86_ ...
- python 之 函数的参数
函数的参数好几种类型:包括位置参数.默认参数.可变参数.关键字参数.命名关键字参数. 廖大神python学习笔记,大神网站:百度搜索“廖雪峰的官网” 1.位置参数:调用函数时根据函数定义的参数位置来传 ...
- hdu 4366 Successor - CDQ分治 - 线段树 - 树分块
Sean owns a company and he is the BOSS.The other Staff has one Superior.every staff has a loyalty an ...