-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildConfig.cs
93 lines (85 loc) · 2.52 KB
/
BuildConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//#define USE_BUILD_TOOLS
using System;
using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using System.Threading;
#if USE_BUILD_TOOLS
public class BuildConfig : Editor, IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
public int callbackOrder => 0;
public static string OutPath;
private static Build.Build build;
//打包前处理
public void OnPreprocessBuild(BuildReport report)
{
bool isReturn = false;
bool isSuccess = false;
build = new Build.Build(Application.dataPath, OutPath,
(isSucc) =>
{
Debug.LogFormat("OnPath succ = {0}", isSucc);
isReturn = true;
isSuccess = isSucc;
},
(isSucc) =>
{
if (isSucc)
{
build.Stop();
}
Debug.LogFormat("Restore succ = {0}", isSucc);
});
EditorUtility.DisplayCancelableProgressBar("BuildConfig", "配置中...", 0.3f);
float pro = 0.3f;
while (!isReturn)
{
Thread.Sleep(10);
pro += 0.1f;
EditorUtility.DisplayCancelableProgressBar("BuildConfig", "配置中...", pro);
}
if (isSuccess)
{
AssetDatabase.Refresh();
}
}
//打包后处理
public void OnPostprocessBuild(BuildReport report)
{
build.Restore();
}
}
#elif USE_JENKINS_TOOLS
public static class BuildConfig
{
public static string OutPath;
public static void EndBuild()
{
bool isReturn = false;
bool isSuccess = false;
Build.Build build = null;
build = new Build.Build(OutPath,
(isSucc) =>
{
isSuccess = isSucc;
isReturn = true;
Debug.LogFormat("Restore succ = {0}", isSucc);
});
EditorUtility.DisplayCancelableProgressBar("BuildConfig", "配置中...", 0.3f);
float pro = 0.98f;
while (!isReturn)
{
Thread.Sleep(10);
pro += 0.001f;
EditorUtility.DisplayCancelableProgressBar("BuildConfig", "配置中...", pro);
}
if (isSuccess)
{
build.Restore();
build.Stop();
}
EditorUtility.ClearProgressBar();
}
}
#endif