|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public static class CIBuildHelper
|
|
|
|
|
{
|
|
|
|
|
static string InitScenePath = "Assets/Scenes/Init.unity";
|
|
|
|
|
public static string BuildOutputPath = "/BuildOutputPath";
|
|
|
|
|
|
|
|
|
|
[MenuItem("CIBuild/BuildIOS")]
|
|
|
|
|
public static void BuildIOS()
|
|
|
|
|
{
|
|
|
|
|
var outDir = System.Environment.CurrentDirectory + BuildOutputPath + "/IOS";
|
|
|
|
|
// var outputPath = Path.Combine(outDir, Application.productName + ".exe");
|
|
|
|
|
BuildTarget target = BuildTarget.iOS;
|
|
|
|
|
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, target);
|
|
|
|
|
|
|
|
|
|
string[] scenes = new[] { InitScenePath };
|
|
|
|
|
Debug.Log("Begin Build IOS");
|
|
|
|
|
UnityEditor.BuildPipeline.BuildPlayer(scenes, outDir, target, BuildOptions.None);
|
|
|
|
|
Debug.Log("End Build IOS");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MenuItem("CIBuild/BuildWin")]
|
|
|
|
|
public static void BuildWin()
|
|
|
|
|
{
|
|
|
|
|
var outDir = System.Environment.CurrentDirectory + BuildOutputPath + "/Win";
|
|
|
|
|
var outputPath = Path.Combine(outDir, Application.productName + ".exe");
|
|
|
|
|
//<EFBFBD>ļ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (!Directory.Exists(outDir)) Directory.CreateDirectory(outDir);
|
|
|
|
|
if (File.Exists(outputPath)) File.Delete(outputPath);
|
|
|
|
|
|
|
|
|
|
//<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ŀһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
string[] scenes = new[] { InitScenePath };
|
|
|
|
|
UnityEditor.BuildPipeline.BuildPlayer(scenes, outputPath, BuildTarget.StandaloneWindows64, BuildOptions.None);
|
|
|
|
|
if (File.Exists(outputPath))
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("Build Success :" + outputPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogException(new Exception("Build Fail! Please Check the log! "));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MenuItem("CIBuild/BuildApk")]
|
|
|
|
|
public static void BuildApk()
|
|
|
|
|
{
|
|
|
|
|
var outDir = System.Environment.CurrentDirectory + BuildOutputPath + "/Android";
|
|
|
|
|
var outputPath = Path.Combine(outDir, Application.productName + ".apk");
|
|
|
|
|
//<EFBFBD>ļ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (!Directory.Exists(outDir)) Directory.CreateDirectory(outDir);
|
|
|
|
|
if (File.Exists(outputPath)) File.Delete(outputPath);
|
|
|
|
|
|
|
|
|
|
//<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ŀһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
string[] scenes = new[] { InitScenePath };
|
|
|
|
|
UnityEditor.BuildPipeline.BuildPlayer(scenes, outputPath, BuildTarget.Android, BuildOptions.None);
|
|
|
|
|
if (File.Exists(outputPath))
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("Build Success :" + outputPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogException(new Exception("Build Fail! Please Check the log! "));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|