1
+ # -*- coding: UTF-8 -*-
2
+
3
+ import os
4
+ import stat
5
+ import ctypes , sys
6
+
7
+ def enum (label , keyList , valueList ):
8
+ print ("\n ======================================================================" )
9
+ print ("- 请选择" + label + ":" )
10
+ for x in range (len (keyList )):
11
+ print ("- " + str (x + 1 ) + ":" + keyList [x ])
12
+ pass
13
+ print ("- other:忽略" )
14
+ index = int (input ('' )) - 1
15
+ maxIndex = len (valueList )
16
+ if (index > maxIndex ):
17
+ return "null"
18
+ for x in range (maxIndex ):
19
+ if (x == index ):
20
+ return valueList [x ]
21
+ pass
22
+ return "null"
23
+
24
+ def UnityRun (MethodArgs ):
25
+ print ("- 请输入 unity.exe 文件路径:" )
26
+ value = str (input ('' ))
27
+ unityExe = "D:\\ Unity\\ Unity2020.3.37f1\\ Editor\\ Unity.exe"
28
+ if (len (value ) > 0 ): unityExe = value
29
+
30
+ # 项目路径
31
+ print ("- 请输入 unity 项目路径:" )
32
+ value = str (input ('' ))
33
+ projectPath = "E:\\ TencentGit\\ AIO20200337\\ "
34
+ if (len (value ) > 0 ): projectPath = value
35
+
36
+ # 日志文件输出路径
37
+ print ("- 请输入 日志文件输出路径:" )
38
+ value = str (input ('' ))
39
+ logfile = "E:\\ TencentGit\\ AIO20200337\\ Build\\ test\\ beedom20230104.android.log"
40
+ if (len (value ) > 0 ): logfile = value
41
+
42
+ # Unity执行函数
43
+ print ("- 请输入 Unity 执行函数:" )
44
+ value = str (input ('' ))
45
+ executeMethod = "AIO.Build.Editor.YooAssetBuild.ArtBuild"
46
+ if (len (value ) > 0 ): executeMethod = value
47
+
48
+ command = unityExe + " -projectPath " + projectPath + " -quit -batchmode -logfile " + logfile + " -executeMethod " + executeMethod + " \" " + MethodArgs + "|\" "
49
+
50
+ print (command )
51
+ print ("\n 开始执行 请稍等" )
52
+ os .system (command )
53
+
54
+ def main ():
55
+ os .system ("@echo off&@setlocal enabledelayedexpansion" )
56
+ os .system ("@chcp 65001&@color F" )
57
+
58
+ ## -----说明文字-----
59
+ print ("\n ======================================================================" )
60
+ print ("- Welcome :美术资源打包" )
61
+ print ("======================================================================\n " )
62
+
63
+ args = []
64
+ #--------------------------------------------------------------
65
+ keyList = []
66
+ keyList .append ("BuiltinBuildPipeline (传统内置构建管线)" )
67
+ keyList .append ("ScriptableBuildPipeline (可编程构建管线)" )
68
+
69
+ valueList = []
70
+ valueList .append ("b@BuildPipeline BuiltinBuildPipeline" )
71
+ valueList .append ("b@BuildPipeline ScriptableBuildPipeline" )
72
+
73
+ value = enum ("BuildPipeline 构建管线类型 (必选)" , keyList , valueList )
74
+ if (value != "null" ): args .append (value )
75
+ #--------------------------------------------------------------
76
+ keyList = []
77
+ keyList .append ("None (不拷贝任何文件)" )
78
+ keyList .append ("ClearAndCopyAll (先清空已有文件,然后拷贝所有文件)" )
79
+ keyList .append ("ClearAndCopyByTags (先清空已有文件,然后按照资源标签拷贝文件)" )
80
+ keyList .append ("OnlyCopyAll (不清空已有文件,直接拷贝所有文件)" )
81
+ keyList .append ("OnlyCopyByTags (不清空已有文件,直接按照资源标签拷贝文件)" )
82
+
83
+ valueList = []
84
+ valueList .append ("b@BuildPipeline None" )
85
+ valueList .append ("b@BuildPipeline ClearAndCopyAll" )
86
+ valueList .append ("b@BuildPipeline ClearAndCopyByTags" )
87
+ valueList .append ("b@BuildPipeline OnlyCopyAll" )
88
+ valueList .append ("b@BuildPipeline OnlyCopyByTags" )
89
+
90
+ value = enum ("BuildPipeline 首包资源文件的拷贝方式: (可忽略)" , keyList , valueList )
91
+ if (value != "null" ): args .append (value )
92
+ #--------------------------------------------------------------
93
+ keyList = []
94
+ keyList .append ("HashName (哈希值名称)" )
95
+ keyList .append ("BundleName_HashName (资源包名称 + 哈希值名称)" )
96
+
97
+ valueList = []
98
+ valueList .append ("b@OutputNameStyle HashName" )
99
+ valueList .append ("b@OutputNameStyle BundleName_HashName" )
100
+
101
+ value = enum ("OutputNameStyle 输出文件名称的样式: (可忽略)" , keyList , valueList )
102
+ if (value != "null" ): args .append (value )
103
+ #--------------------------------------------------------------
104
+ keyList = []
105
+ keyList .append ("ForceRebuild (强制重建模式)" )
106
+ keyList .append ("IncrementalBuild (增量构建模式)" )
107
+ keyList .append ("DryRunBuild (演练构建模式)" )
108
+ keyList .append ("SimulateBuild (模拟构建模式)" )
109
+
110
+ valueList = []
111
+ valueList .append ("b@BuildMode ForceRebuild" )
112
+ valueList .append ("b@BuildMode IncrementalBuild" )
113
+ valueList .append ("b@BuildMode DryRunBuild" )
114
+ valueList .append ("b@BuildMode SimulateBuild" )
115
+
116
+ value = enum ("BuildMode 资源包流水线的构建模式: (可忽略)" , keyList , valueList )
117
+ if (value != "null" ): args .append (value )
118
+ #--------------------------------------------------------------
119
+ keyList = []
120
+ keyList .append ("Android (安卓)" )
121
+ keyList .append ("iOS (苹果)" )
122
+ keyList .append ("WebGL (Web网页)" )
123
+ keyList .append ("StandaloneWindows (PC)" )
124
+
125
+ valueList = []
126
+ valueList .append ("b@ActiveTarget Android" )
127
+ valueList .append ("b@ActiveTarget iOS" )
128
+ valueList .append ("b@ActiveTarget WebGL" )
129
+ valueList .append ("b@ActiveTarget StandaloneWindows" )
130
+
131
+ value = enum ("ActiveTarget 资源打包目标平台: (可忽略)" , keyList , valueList )
132
+ if (value != "null" ): args .append (value )
133
+ #--------------------------------------------------------------
134
+ keyList = []
135
+ keyList .append ("Uncompressed" )
136
+ keyList .append ("LZMA" )
137
+ keyList .append ("LZ4" )
138
+
139
+ valueList = []
140
+ valueList .append ("b@CompressOption Uncompressed" )
141
+ valueList .append ("b@CompressOption LZMA" )
142
+ valueList .append ("b@CompressOption LZ4" )
143
+
144
+ value = enum ("CompressOption AssetBundle压缩选项: (可忽略)" , keyList , valueList )
145
+ if (value != "null" ): args .append (value )
146
+ #--------------------------------------------------------------
147
+ print ("- 请输入 输出根目录:" )
148
+ value = str (input ('' ))
149
+ if (len (value ) > 0 ): args .append ("b@OutputRoot " + value )
150
+ #--------------------------------------------------------------
151
+ print ("- 请输入 资源目标包:" )
152
+ value = str (input ('' ))
153
+ if (len (value ) > 0 ): args .append ("b@BuildPackage " + value )
154
+ #--------------------------------------------------------------
155
+ print ("- 请输入 资源目标版本:" )
156
+ value = str (input ('' ))
157
+ if (len (value ) > 0 ): args .append ("b@PackageVersion " + value )
158
+ #--------------------------------------------------------------
159
+ print ("- 请输入 首包资源文件的标签集合: (可忽略)" )
160
+ value = str (input ('' ))
161
+ if (len (value ) > 0 ): args .append ("b@CopyBuildinFileTags " + value )
162
+ #--------------------------------------------------------------
163
+ print ("- 请输入 加密类名称: (可忽略)" )
164
+ value = str (input ('' ))
165
+ if (len (value ) > 0 ): args .append ("b@EncyptionClassName " + value )
166
+ #--------------------------------------------------------------
167
+ print ("- 请输入 验证构建结果 1:验证 other:忽略 (可忽略)" )
168
+ value = str (input ('' ))
169
+ if (value == "1" ): args .append ("b@VerifyBuildingResult " )
170
+
171
+ print ("\n ======================================================================" )
172
+ arg = ''
173
+ for index in range (len (args )):
174
+ arg = arg + ' ' + args [index ]
175
+ print (args [index ])
176
+ pass
177
+ print ("======================================================================\n " )
178
+
179
+ UnityRun (arg )
180
+
181
+
182
+ print ("- 打包完成: 输入任意键退出本程序" )
183
+ str (input ('' ))
184
+
185
+ def is_admin ():
186
+ try : return ctypes .windll .shell32 .IsUserAnAdmin ()
187
+ except : return False
188
+
189
+ if is_admin (): main ()
190
+ else : ctypes .windll .shell32 .ShellExecuteW (None , "runas" , sys .executable , __file__ , None , 1 )
0 commit comments