remove buildcli
This commit is contained in:
parent
28036786c8
commit
d124be0855
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aaa18fe06ddc42c0872e3178d851e588
|
||||
timeCreated: 1742451366
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69ea7963a8cfa4645b9345e57aef8331
|
||||
timeCreated: 1737867267
|
||||
@ -1,98 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using AlicizaX.Editor;
|
||||
using AlicizaX;
|
||||
using AlicizaX.Debugger.Runtime;
|
||||
using AlicizaX.Framework.Runtime.ABase;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class AppBuildHelper
|
||||
{
|
||||
public static void GeneratAppBuilderSetting(string language, DebuggerActiveWindowType debugMode, int resMode)
|
||||
{
|
||||
const string AppBuilderSettingPath = "Assets/Resources/ModuleDynamicBindInfo.bytes";
|
||||
ModuleDynamicBindInfo appBuilderSetting = new ModuleDynamicBindInfo();
|
||||
appBuilderSetting.Language = language;
|
||||
appBuilderSetting.DebuggerActiveWindowType = debugMode;
|
||||
appBuilderSetting.ResMode = resMode;
|
||||
File.WriteAllText(AppBuilderSettingPath, Utility.Json.ToJson(appBuilderSetting));
|
||||
}
|
||||
|
||||
public static void BuildApplication(AppBuildParameter appBuildParameter, bool showExplorer = false)
|
||||
{
|
||||
if (!Directory.Exists(appBuildParameter.OutPutPath))
|
||||
{
|
||||
Directory.CreateDirectory(appBuildParameter.OutPutPath);
|
||||
}
|
||||
|
||||
Debug.Log("Starting build application");
|
||||
|
||||
GeneratAppBuilderSetting(appBuildParameter.Language, appBuildParameter.ShowDebugWnd, appBuildParameter.ResMode);
|
||||
|
||||
Debug.Log("Generate AppBuilderSetting.bytes");
|
||||
|
||||
PlayerSettings.fullScreenMode = appBuildParameter.FullScreenMode;
|
||||
if (appBuildParameter.FullScreenMode == FullScreenMode.Windowed)
|
||||
{
|
||||
PlayerSettings.defaultScreenWidth = appBuildParameter.WindowedScreenSize.x;
|
||||
PlayerSettings.defaultScreenHeight = appBuildParameter.WindowedScreenSize.y;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(appBuildParameter.Version))
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var options = new BuildPlayerOptions
|
||||
{
|
||||
scenes = appBuildParameter.Scenes,
|
||||
locationPathName = Path.Combine(appBuildParameter.OutPutPath, appBuildParameter.FileName),
|
||||
target = appBuildParameter.BuildTarget,
|
||||
options = appBuildParameter.DevelopBuild ? BuildOptions.Development : BuildOptions.None
|
||||
};
|
||||
|
||||
var report = BuildPipeline.BuildPlayer(options);
|
||||
HandleBuildReport(report);
|
||||
if (showExplorer)
|
||||
{
|
||||
DirectoryInfo directoryInfo = Directory.GetParent(report.summary.outputPath);
|
||||
if (directoryInfo != null) OpenFolder.Execute(directoryInfo.FullName);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log($"构建过程中发生异常: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleBuildReport(UnityEditor.Build.Reporting.BuildReport report)
|
||||
{
|
||||
if (report.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||
{
|
||||
Debug.Log($"整包构建完成:${report.summary.outputPath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
Debug.LogError(report.SummarizeErrors());
|
||||
#else
|
||||
var errors = new List<string>();
|
||||
foreach (var step in report.steps)
|
||||
{
|
||||
foreach (var msg in step.messages)
|
||||
{
|
||||
if (msg.type == LogType.Error || msg.type == LogType.Exception)
|
||||
{
|
||||
errors.Add($"[Step: {step.name}] {msg.content}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Debug.LogError($"构建失败,错误信息:\n{string.Join("\n", errors)}");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 154ce1f8cc3455246af4a6501d246f02
|
||||
timeCreated: 1740128549
|
||||
@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using AlicizaX;
|
||||
using AlicizaX.Debugger.Runtime;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using YooAsset;
|
||||
using YooAsset.Editor;
|
||||
|
||||
|
||||
public class AppBuildParameter
|
||||
{
|
||||
public BuildTarget BuildTarget;
|
||||
public string OutPutPath;
|
||||
public DebuggerActiveWindowType ShowDebugWnd;
|
||||
public bool DevelopBuild;
|
||||
public int ResMode;
|
||||
public string FileName;
|
||||
public string Language;
|
||||
public string[] Scenes;
|
||||
|
||||
/// <summary>
|
||||
/// 版本
|
||||
/// </summary>
|
||||
public string Version;
|
||||
|
||||
/// <summary>
|
||||
/// 是否全屏
|
||||
/// </summary>
|
||||
public FullScreenMode FullScreenMode;
|
||||
|
||||
/// <summary>
|
||||
/// 窗口化大小
|
||||
/// </summary>
|
||||
public Vector2Int WindowedScreenSize;
|
||||
}
|
||||
|
||||
|
||||
public class ResourceBuildParameter
|
||||
{
|
||||
public BuildTarget ResourceBuildTarget;
|
||||
public string PackageVersion;
|
||||
public bool UseDefaultPackageVersion;
|
||||
public string OutputPath;
|
||||
public ResourceBuildMode BuildMode;
|
||||
|
||||
public ECompressOption CompressOption = ECompressOption.LZ4;
|
||||
public EFileNameStyle FileNameStyle = EFileNameStyle.BundleName_HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 从文件头里剥离Unity版本信息
|
||||
/// </summary>
|
||||
public bool StripUnityVersion = false;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化(无效参数)
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自动建立资源对象对图集的依赖关系
|
||||
/// </summary>
|
||||
public bool TrackSpriteAtlasDependencies = false;
|
||||
|
||||
public string EncryptionServiceType = "AlicizaX.Resource.Editor.FileOffsetEncryption";
|
||||
}
|
||||
|
||||
public enum ResourceBuildMode
|
||||
{
|
||||
Offline,
|
||||
Online,
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d5b605d55cc82844b76260841f92475
|
||||
timeCreated: 1741577226
|
||||
@ -1,135 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
using YooAsset.Editor;
|
||||
|
||||
public static class ResourceBuildHelper
|
||||
{
|
||||
private const bool EnableSharePack = true;
|
||||
private const string BuildPackageName = "DefaultPackage";
|
||||
|
||||
private static string GeneratePackageVersion()
|
||||
{
|
||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||
}
|
||||
|
||||
public static void BuildResourcePackage(ResourceBuildParameter buildParameter)
|
||||
{
|
||||
if (!Directory.Exists(buildParameter.OutputPath))
|
||||
{
|
||||
Directory.CreateDirectory(buildParameter.OutputPath);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string copyParams = string.Empty;
|
||||
EBuildinFileCopyOption copyOption = EBuildinFileCopyOption.None;
|
||||
if (buildParameter.BuildMode == ResourceBuildMode.Online)
|
||||
{
|
||||
copyOption = EBuildinFileCopyOption.ClearAndCopyByTags;
|
||||
copyParams = "Launch";
|
||||
}
|
||||
else
|
||||
{
|
||||
copyOption = EBuildinFileCopyOption.ClearAndCopyAll;
|
||||
}
|
||||
|
||||
var parameters = new ScriptableBuildParameters
|
||||
{
|
||||
BuildOutputRoot = buildParameter.OutputPath,
|
||||
BuildTarget = buildParameter.ResourceBuildTarget,
|
||||
PackageName = BuildPackageName,
|
||||
BuildBundleType = (int)EBuildBundleType.AssetBundle,
|
||||
BuildPipeline = EBuildPipeline.ScriptableBuildPipeline.ToString(),
|
||||
BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(),
|
||||
PackageVersion = buildParameter.UseDefaultPackageVersion ? GeneratePackageVersion() : buildParameter.PackageVersion,
|
||||
CompressOption = buildParameter.CompressOption,
|
||||
BuiltinShadersBundleName = GetBuiltinShaderBundleName(),
|
||||
VerifyBuildingResult = true,
|
||||
ClearBuildCacheFiles = false,
|
||||
BuildinFileCopyOption = copyOption,
|
||||
BuildinFileCopyParams = copyParams,
|
||||
EnableSharePackRule = EnableSharePack,
|
||||
FileNameStyle = buildParameter.FileNameStyle,
|
||||
EncryptionServices = CreateEncryptionInstance(buildParameter.EncryptionServiceType),
|
||||
ReplaceAssetPathWithAddress = buildParameter.ReplaceAssetPathWithAddress,
|
||||
StripUnityVersion = buildParameter.StripUnityVersion,
|
||||
DisableWriteTypeTree = buildParameter.DisableWriteTypeTree,
|
||||
IgnoreTypeTreeChanges = buildParameter.IgnoreTypeTreeChanges,
|
||||
TrackSpriteAtlasDependencies = buildParameter.TrackSpriteAtlasDependencies,
|
||||
};
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var report = pipeline.Run(parameters, true);
|
||||
|
||||
if (report.Success)
|
||||
{
|
||||
// if (_copyAfterBuild && !string.IsNullOrEmpty(_copyDestination))
|
||||
// {
|
||||
// CopyFiles(report.OutputPackageDirectory, _copyDestination);
|
||||
// }
|
||||
Debug.Log($"AB包构建完成!\n输出目录: {report.OutputPackageDirectory}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"错误信息: {report.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 内置着色器资源包名称
|
||||
/// 注意:和自动收集的着色器资源包名保持一致!
|
||||
/// </summary>
|
||||
private static string GetBuiltinShaderBundleName()
|
||||
{
|
||||
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
return packRuleResult.GetBundleName(BuildPackageName, uniqueBundleName);
|
||||
}
|
||||
|
||||
private static void CopyFiles(string source, string destination)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(destination))
|
||||
{
|
||||
Directory.CreateDirectory(destination);
|
||||
}
|
||||
|
||||
foreach (string file in Directory.GetFiles(source))
|
||||
{
|
||||
File.Copy(file, Path.Combine(destination, Path.GetFileName(file)), true);
|
||||
}
|
||||
|
||||
Debug.Log($"文件拷贝完成: {source} -> {destination}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"文件拷贝失败: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static IEncryptionServices CreateEncryptionInstance(string encryptionService)
|
||||
{
|
||||
if (string.IsNullOrEmpty(encryptionService)) return null;
|
||||
|
||||
var type = Type.GetType(encryptionService);
|
||||
if (type != null)
|
||||
{
|
||||
return (IEncryptionServices)Activator.CreateInstance(type);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0418e1e75999064ca53a72ff542a08c
|
||||
timeCreated: 1740128311
|
||||
Loading…
Reference in New Issue
Block a user