@@ -265,35 +265,43 @@ private static void SaveConfig()
265
265
//资源打包
266
266
private static string BuildTarget ( BuildTarget target )
267
267
{
268
- //打包路径
269
- string targetName = $ "{ Application . version } _{ _config . Version } ";
270
- string buildPath = Path . Combine ( _config . BuildPath , BuildTargetToString ( target ) , targetName ) ; ;
271
- if ( ! Directory . Exists ( buildPath ) )
272
- Directory . CreateDirectory ( buildPath ) ;
273
- //设置打包的相关选项
274
- BuildAssetBundleOptions options = BuildAssetBundleOptions . None ;
275
- //设置压缩 默认LZMA
276
- if ( _config . CompressOptions == 0 )
277
- options |= BuildAssetBundleOptions . UncompressedAssetBundle ;
278
- //LZ4
279
- else if ( _config . CompressOptions == 2 )
280
- options |= BuildAssetBundleOptions . ChunkBasedCompression ;
281
- //打包 Build
282
- if ( _config . UseAssetBundleEditor )
268
+ try
283
269
{
284
- BuildPipeline . BuildAssetBundles ( buildPath , AssetBundleEditor . GetAssetBundleBuild ( ) , options , target ) ;
270
+ //打包路径
271
+ string targetName = $ "{ Application . version } _{ _config . Version } ";
272
+ string buildPath = Path . Combine ( _config . BuildPath , BuildTargetToString ( target ) , targetName ) ; ;
273
+ if ( ! Directory . Exists ( buildPath ) )
274
+ Directory . CreateDirectory ( buildPath ) ;
275
+ //设置打包的相关选项
276
+ BuildAssetBundleOptions options = BuildAssetBundleOptions . None ;
277
+ //设置压缩 默认LZMA
278
+ if ( _config . CompressOptions == 0 )
279
+ options |= BuildAssetBundleOptions . UncompressedAssetBundle ;
280
+ //LZ4
281
+ else if ( _config . CompressOptions == 2 )
282
+ options |= BuildAssetBundleOptions . ChunkBasedCompression ;
283
+ //打包 Build
284
+ if ( _config . UseAssetBundleEditor )
285
+ {
286
+ BuildPipeline . BuildAssetBundles ( buildPath , AssetBundleEditor . GetAssetBundleBuild ( ) , options , target ) ;
287
+ }
288
+ else
289
+ {
290
+ BuildPipeline . BuildAssetBundles ( buildPath , options , target ) ;
291
+ }
292
+ //保存资源版本信息
293
+ SaveAssetVersion ( buildPath , targetName , target ) ;
294
+ Debug . Log ( $ "资源打包成功: { buildPath } ") ;
295
+ // //更新资源版本号 -- 保存配置文件
296
+ _config . Version ++ ;
297
+ SaveConfig ( ) ;
298
+ return buildPath ;
285
299
}
286
- else
300
+ catch ( System . Exception e )
287
301
{
288
- BuildPipeline . BuildAssetBundles ( buildPath , options , target ) ;
302
+ throw new GameException ( $ "Build assetbundle error [ { target . ToString ( ) } ] : { e . ToString ( ) } " ) ;
289
303
}
290
- //保存资源版本信息
291
- SaveAssetVersion ( buildPath , targetName , target ) ;
292
- Debug . Log ( $ "资源打包成功: { buildPath } ") ;
293
- // //更新资源版本号 -- 保存配置文件
294
- _config . Version ++ ;
295
- SaveConfig ( ) ;
296
- return buildPath ;
304
+
297
305
}
298
306
299
307
//保存资源版本信息
0 commit comments