【m】框架优化
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
|
||||
{
|
||||
string platform = EditorPrefs.GetString("ChangePlayerSchema");
|
||||
string platform = CustomEditorPrefs.GetString("ChangePlayerSchema");
|
||||
// build前
|
||||
if (Enum.Parse<PLayerMode>(platform) == PLayerMode.EDITOR_SIMULATEMODE)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
public void OnEnable()
|
||||
{
|
||||
viewer = new ScriptableBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(),
|
||||
viewer = new MixedBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(),
|
||||
packageVersion);
|
||||
oldVersionX = packageVersionX;
|
||||
oldVersionY = packageVersionY;
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Stary.Evo.Editor
|
||||
/// <returns></returns>
|
||||
private void SetBuildPackageNames()
|
||||
{
|
||||
//PlayerPrefs.SetString("BuildPackageNames", selectedPackageNames);
|
||||
//CustomPlayerPrefs.SetString("BuildPackageNames", selectedPackageNames);
|
||||
// DataSetting.packageName = selectedPackageNames;
|
||||
|
||||
|
||||
@@ -248,69 +248,94 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
|
||||
|
||||
public static string BuildZip(BuildAssetDataSetting setting)
|
||||
public static string BuildZip(BuildAssetDataSetting setting)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.0f);
|
||||
// 新增:打包为zip的逻辑
|
||||
string zipFileName =
|
||||
$"{setting.packageName}_{setting.packageVersion}.zip";
|
||||
//原yooAsset目录
|
||||
var outputPackageDirectory =
|
||||
$"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}";
|
||||
|
||||
//RawFile目录路径
|
||||
var outputRawFileDirectory =
|
||||
$"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}_RawFile";
|
||||
|
||||
//拷贝目录
|
||||
string outFilePath = $"{outputPackageDirectory}/{setting.packageVersion}";
|
||||
string outRawFilePath = $"{outputRawFileDirectory}/{setting.packageVersion}";
|
||||
|
||||
var copyPackageDirectory =
|
||||
$"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}";
|
||||
|
||||
//拷贝BuildinCatalog文件
|
||||
CreateBuildinCatalogFile("BuildinCatalog.json", copyPackageDirectory, outFilePath);
|
||||
CreateBuildinCatalogFile("BuildinCatalog.bytes", copyPackageDirectory, outFilePath);
|
||||
|
||||
var copyRawFilePackageDirectory =
|
||||
$"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}_RawFile";
|
||||
CreateBuildinCatalogFile("BuildinCatalog.json", copyRawFilePackageDirectory, outRawFilePath);
|
||||
CreateBuildinCatalogFile("BuildinCatalog.bytes", copyRawFilePackageDirectory, outRawFilePath);
|
||||
//输出目录
|
||||
string zipFilePath = Path.Combine(outputPackageDirectory, zipFileName);
|
||||
try
|
||||
{
|
||||
using (FileStream zipStream = new FileStream(zipFilePath, FileMode.Create))
|
||||
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.0f);
|
||||
// 新增:打包为zip的逻辑
|
||||
string zipFileName =
|
||||
$"{setting.packageName}_{setting.packageVersion}.zip";
|
||||
//原yooAsset目录
|
||||
var outputPackageDirectory =
|
||||
$"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}";
|
||||
|
||||
//拷贝目录
|
||||
string outFilePath = $"{outputPackageDirectory}/{setting.packageVersion}";
|
||||
|
||||
var copyPackageDirectory =
|
||||
$"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}";
|
||||
//拷贝BuildinCatalog文件
|
||||
CreateBuildinCatalogFile("BuildinCatalog.json", copyPackageDirectory, outFilePath);
|
||||
CreateBuildinCatalogFile("BuildinCatalog.bytes", copyPackageDirectory, outFilePath);
|
||||
|
||||
//输出目录
|
||||
string zipFilePath = Path.Combine(outputPackageDirectory, zipFileName);
|
||||
try
|
||||
// 打包主包文件
|
||||
foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
using (FileStream zipStream = new FileStream(zipFilePath, FileMode.Create))
|
||||
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
|
||||
// 获取文件在压缩包中的相对路径
|
||||
string entryName =$"{setting.packageName}/{ Path.GetRelativePath(outFilePath, filePath)}";
|
||||
// 创建zip条目
|
||||
ZipArchiveEntry entry = archive.CreateEntry(entryName,
|
||||
System.IO.Compression.CompressionLevel.Optimal);
|
||||
|
||||
// 写入文件内容
|
||||
using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
using (Stream entryStream = entry.Open())
|
||||
{
|
||||
// 指定需要压缩的后缀(例如:只压缩.json和.dll文件)
|
||||
//string[] targetExtensions = { ".bundle" };
|
||||
fileStream.CopyTo(entryStream);
|
||||
}
|
||||
}
|
||||
|
||||
// 打包RawFile文件
|
||||
if (Directory.Exists(outRawFilePath))
|
||||
{
|
||||
foreach (string filePath in Directory.GetFiles(outRawFilePath, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
// 获取文件在压缩包中的相对路径
|
||||
string entryName =$"{setting.packageName}_RawFile/{ Path.GetRelativePath(outRawFilePath, filePath)}";
|
||||
|
||||
// 遍历目录下所有文件
|
||||
// foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories)
|
||||
// .Where(f => targetExtensions.Contains(Path.GetExtension(f),
|
||||
// StringComparer.OrdinalIgnoreCase)))
|
||||
foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories))
|
||||
// 创建zip条目
|
||||
ZipArchiveEntry entry = archive.CreateEntry(entryName,
|
||||
System.IO.Compression.CompressionLevel.Optimal);
|
||||
|
||||
// 写入文件内容
|
||||
using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
using (Stream entryStream = entry.Open())
|
||||
{
|
||||
// 获取文件在压缩包中的相对路径
|
||||
string entryName = Path.GetRelativePath(outFilePath, filePath);
|
||||
|
||||
// 创建zip条目
|
||||
ZipArchiveEntry entry = archive.CreateEntry(entryName,
|
||||
System.IO.Compression.CompressionLevel.Optimal);
|
||||
|
||||
// 写入文件内容
|
||||
using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
using (Stream entryStream = entry.Open())
|
||||
{
|
||||
fileStream.CopyTo(entryStream);
|
||||
}
|
||||
fileStream.CopyTo(entryStream);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"成功打包为zip:{zipFilePath}");
|
||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.25f);
|
||||
return zipFilePath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"打包zip失败:{ex.Message}");
|
||||
EditorUtility.ClearProgressBar();
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"成功打包为zip:{zipFilePath}");
|
||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.25f);
|
||||
return zipFilePath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"打包zip失败:{ex.Message}");
|
||||
EditorUtility.ClearProgressBar();
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void CreateBuildinCatalogFile(string fileName, string copyPackageDirectory, string outFilePath)
|
||||
{
|
||||
// 假设 BuildinCatalog 文件名为 BuildinCatalog.json
|
||||
@@ -332,7 +357,7 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
|
||||
|
||||
string ip = EditorPrefs.GetString("ip");
|
||||
string ip = CustomEditorPrefs.GetString("ip");
|
||||
var messageEntity = await WebRequestSystem.PostFile(ip + "/FileLoad/UpLoadFile", new[] { zipFilePath });
|
||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(上传zip文件)", 0.5f);
|
||||
if (messageEntity.code == 200)
|
||||
@@ -403,7 +428,7 @@ namespace Stary.Evo.Editor
|
||||
DomainName = selectedPackageNames,
|
||||
Platform = EditorUserBuildSettings.activeBuildTarget.ToString(),
|
||||
};
|
||||
var resResultMessage = await WebRequestSystem.Post(EditorPrefs.GetString("ip") + "/ResDomain/GetResDomainByDomain",
|
||||
var resResultMessage = await WebRequestSystem.Post(CustomEditorPrefs.GetString("ip") + "/ResDomain/GetResDomainByDomain",
|
||||
JsonConvert.SerializeObject(resDmainAddRequst));
|
||||
//如果低于服务器版本,更新版本号
|
||||
if (resResultMessage.code != 1011)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Stary.Evo.Editor
|
||||
[MenuItem(EditorNotUpdateMode, true)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
string platform = EditorPrefs.GetString("ChangeHotUpdateSchema");
|
||||
string platform = CustomEditorPrefs.GetString("ChangeHotUpdateSchema");
|
||||
Menu.SetChecked(EditorNotUpdateMode, platform == HotUpdateMode.NotUpdate.ToString());
|
||||
Menu.SetChecked(EditorHotUpdateMode, platform == HotUpdateMode.HotUpdate.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
|
||||
@@ -54,7 +54,7 @@ namespace Stary.Evo.Editor
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
|
||||
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
|
||||
_hotUpdate = mode;
|
||||
EditorPrefs.SetString("ChangeHotUpdateSchema", _hotUpdate.ToString());
|
||||
CustomEditorPrefs.SetString("ChangeHotUpdateSchema", _hotUpdate.ToString());
|
||||
|
||||
ValidateModeMenu();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Stary.Evo.Editor
|
||||
[MenuItem(EditorSimulateMode, true,3)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
string platform = EditorPrefs.GetString("ChangePlayerSchema");
|
||||
string platform = CustomEditorPrefs.GetString("ChangePlayerSchema");
|
||||
Menu.SetChecked(EditorSimulateMode, platform == PLayerMode.EDITOR_SIMULATEMODE.ToString());
|
||||
Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString());
|
||||
@@ -54,7 +54,7 @@ namespace Stary.Evo.Editor
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
|
||||
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
|
||||
_pLayerMode = mode;
|
||||
EditorPrefs.SetString("ChangePlayerSchema", _pLayerMode.ToString());
|
||||
CustomEditorPrefs.SetString("ChangePlayerSchema", _pLayerMode.ToString());
|
||||
ValidateModeMenu();
|
||||
AssetDatabase.Refresh();
|
||||
// 添加解决方案文件重新生成逻辑
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Stary.Evo.Editor
|
||||
[MenuItem(EditorNotMode, true)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
string platform = EditorPrefs.GetString("ChangePoindClondSchema");
|
||||
string platform = CustomEditorPrefs.GetString("ChangePoindClondSchema");
|
||||
Menu.SetChecked(EditorNotMode, platform == PointClondMode.NotPointClond.ToString());
|
||||
Menu.SetChecked(EditorImmersalMode, platform == PointClondMode.Immersal.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
|
||||
@@ -54,7 +54,7 @@ namespace Stary.Evo.Editor
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
|
||||
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
|
||||
_pointClondMode = mode;
|
||||
EditorPrefs.SetString("ChangePoindClondSchema", _pointClondMode.ToString());
|
||||
CustomEditorPrefs.SetString("ChangePoindClondSchema", _pointClondMode.ToString());
|
||||
|
||||
ValidateModeMenu();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
@@ -17,15 +17,15 @@ namespace Stary.Evo
|
||||
|
||||
Debug.Log(" 自动运行 ");
|
||||
|
||||
if (!EditorPrefs.HasKey("StartUp"))
|
||||
if (!CustomEditorPrefs.HasKey("StartUp"))
|
||||
{
|
||||
// 通过标记记录是否已经执行过该方法
|
||||
OnEditorStartUp();
|
||||
EditorPrefs.SetInt("StartUp", 1);
|
||||
CustomEditorPrefs.SetInt("StartUp", 1);
|
||||
|
||||
if (EditorPrefs.GetInt("CreatDomainDirectory") == 0)
|
||||
if (CustomEditorPrefs.GetInt("CreatDomainDirectory") == 0)
|
||||
{
|
||||
EditorPrefs.SetInt("CreatDomainDirectory", 1);
|
||||
CustomEditorPrefs.SetInt("CreatDomainDirectory", 1);
|
||||
bool isOk = EditorUtility.DisplayDialog("提示", "发现目录存在缺失,是否检索并创建缺失目录", "是", "否");
|
||||
if (isOk)
|
||||
{
|
||||
@@ -37,17 +37,17 @@ namespace Stary.Evo
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorPrefs.GetString("ChangeHotUpdateSchema") == "")
|
||||
if (CustomEditorPrefs.GetString("ChangeHotUpdateSchema") == "")
|
||||
{
|
||||
ChangeHotUpdateSchema.SetHotUpdateMode(HotUpdateMode.NotUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeHotUpdateSchema.SetHotUpdateMode(
|
||||
Enum.Parse<HotUpdateMode>(EditorPrefs.GetString("ChangeHotUpdateSchema")));
|
||||
Enum.Parse<HotUpdateMode>(CustomEditorPrefs.GetString("ChangeHotUpdateSchema")));
|
||||
}
|
||||
|
||||
if (EditorPrefs.GetString("ChangePlayerSchema") == "")
|
||||
if (CustomEditorPrefs.GetString("ChangePlayerSchema") == "")
|
||||
{
|
||||
ChangePlayerSchema.SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Stary.Evo.Editor
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(packageName,
|
||||
selectedBuildPipelines, copyBuildinFileOption);
|
||||
|
||||
//PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
|
||||
//CustomPlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
|
||||
}
|
||||
|
||||
private void SetCopyBuildinFileParams()
|
||||
@@ -126,7 +126,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(packageName,
|
||||
selectedBuildPipelines, copyBuildinFileParams);
|
||||
//PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
|
||||
//CustomPlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
|
||||
}
|
||||
|
||||
public void SetBuildCacheToggle()
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
using YooAsset.Editor;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class MixedBuildPipelineViewer : AbstractBuildPipelineViewer
|
||||
{
|
||||
public MixedBuildPipelineViewer(string packageName, string selectedBuildPipelines, string packageVersion) :
|
||||
base(packageName, selectedBuildPipelines, packageVersion)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteBuild()
|
||||
{
|
||||
// 1. 首先使用RawFileBuildPipeline打包视频文件
|
||||
Debug.Log("开始使用ScriptableBuildPipeline打包其余文件...");
|
||||
var scriptableBuildResult = BuildOtherFiles();
|
||||
if (!scriptableBuildResult.Success)
|
||||
{
|
||||
Debug.LogError("其余文件打包失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 然后使用ScriptableBuildPipeline打包其余文件
|
||||
Debug.Log("开始使用RawFileBuildPipeline打包视频文件...");
|
||||
var rawBuildResult = BuildRawFiles();
|
||||
if (!rawBuildResult.Success)
|
||||
{
|
||||
Debug.LogError("视频文件打包失败!");
|
||||
return;
|
||||
}
|
||||
Debug.Log("混合打包完成!");
|
||||
base.ExecuteBuild();
|
||||
}
|
||||
|
||||
private BuildResult BuildRawFiles()
|
||||
{
|
||||
var rawPackageName = $"{packageName}_RawFile";
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(packageName, selectedBuildPipelines);
|
||||
var buildinFileCopyOption =
|
||||
AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(packageName, selectedBuildPipelines);
|
||||
var buildinFileCopyParams =
|
||||
AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(packageName, selectedBuildPipelines);
|
||||
var clearBuildCache =
|
||||
AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
|
||||
var useAssetDependencyDB =
|
||||
AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
|
||||
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = selectedBuildPipelines;
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.PackageName = rawPackageName;
|
||||
buildParameters.PackageVersion = packageVersion;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
// SetVideoGroupActive(true);
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
return pipeline.Run(buildParameters, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private BuildResult BuildOtherFiles()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(packageName, selectedBuildPipelines);
|
||||
var buildinFileCopyOption =
|
||||
AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(packageName, selectedBuildPipelines);
|
||||
var buildinFileCopyParams =
|
||||
AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(packageName, selectedBuildPipelines);
|
||||
var compressOption =
|
||||
AssetBundleBuilderSetting.GetPackageCompressOption(packageName, selectedBuildPipelines);
|
||||
var useAssetDependencyDB =
|
||||
AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
|
||||
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
|
||||
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
||||
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = selectedBuildPipelines;
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = packageVersion;
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var result = pipeline.Run(buildParameters, true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// private void SetVideoGroupActive(bool isActive)
|
||||
// {
|
||||
// var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
|
||||
// if (setting == null)
|
||||
// {
|
||||
// Debug.LogError("UnityEvo: 打包设置获取失败,请检查AssetBundleCollectorSettingData设置!");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 使用LINQ简化Package查找
|
||||
// var collectorPackage = setting.Packages.Find(p => p.PackageName == packageName);
|
||||
// if (collectorPackage == null)
|
||||
// {
|
||||
// Debug.LogError($"UnityEvo: 打包视频文件失败【{packageName}】...未找到对应的Package文件,请检查");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 定义激活和禁用规则名称
|
||||
// string enableRule = nameof(EnableGroup);
|
||||
// string disableRule = nameof(DisableGroup);
|
||||
//
|
||||
// // 遍历所有组并设置激活规则
|
||||
// foreach (var group in collectorPackage.Groups)
|
||||
// {
|
||||
// // 使用三元运算符简化逻辑,减少重复代码
|
||||
// bool shouldEnableGroup = group.GroupName == "Video" ? isActive : !isActive;
|
||||
// group.ActiveRuleName = shouldEnableGroup ? enableRule : disableRule;
|
||||
// }
|
||||
//
|
||||
// YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0023f14896b4a189fd6e7c7d4d6072b
|
||||
timeCreated: 1767687803
|
||||
@@ -40,7 +40,6 @@ namespace Stary.Evo.Editor
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Stary.Evo
|
||||
else
|
||||
{
|
||||
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
|
||||
EditorPrefs.SetString("ip", ip);
|
||||
CustomEditorPrefs.SetString("ip", ip);
|
||||
userName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
|
||||
password = hotfixMainResDomain.hotfixMainResDomainEntity.password;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace Stary.Evo
|
||||
{
|
||||
buildAssetType = BuildAssetType.Login;
|
||||
message = "未登录";
|
||||
EditorPrefs.DeleteKey("Authorization");
|
||||
CustomEditorPrefs.DeleteKey("Authorization");
|
||||
}
|
||||
|
||||
private void SetWebRequestInfo()
|
||||
@@ -106,7 +106,7 @@ namespace Stary.Evo
|
||||
hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig = ip;
|
||||
hotfixMainResDomain.hotfixMainResDomainEntity.username = userName;
|
||||
hotfixMainResDomain.hotfixMainResDomainEntity.password = password;
|
||||
EditorPrefs.SetString("ip", ip);
|
||||
CustomEditorPrefs.SetString("ip", ip);
|
||||
EditorUtility.SetDirty(hotfixMainResDomain);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
#if HotUpdate
|
||||
using HybridCLR.Editor;
|
||||
@@ -17,14 +18,22 @@ namespace Stary.Evo.Editor
|
||||
public class MarkAdressable
|
||||
{
|
||||
private static AssetBundleCollectorPackage package;
|
||||
private static string _packageName;
|
||||
private static AssetBundleCollectorPackage packageRawFile;
|
||||
|
||||
|
||||
private static Dictionary<string, string> addressDic = new Dictionary<string, string>();
|
||||
|
||||
private static Dictionary<string, AssetBundleCollectorGroup> _collectorGroupDic =
|
||||
new Dictionary<string, AssetBundleCollectorGroup>();
|
||||
|
||||
private static string _packageName;
|
||||
private static string[] rawFiles = new[] { "Video" };
|
||||
|
||||
public static string DomainRoot
|
||||
{
|
||||
get { return Application.dataPath + "/Domain"; }
|
||||
}
|
||||
|
||||
|
||||
public static void AddHotfixAddressableDll()
|
||||
{
|
||||
CopyDllHotUpdateAssembly(BuildAssetWindow.GetBuildPackageName(),
|
||||
@@ -136,26 +145,9 @@ namespace Stary.Evo.Editor
|
||||
|
||||
public static void AddDomainMark()
|
||||
{
|
||||
// //清空主包旧数据
|
||||
AssetBundleCollectorPackage assetBundleCollectorPackage = null;
|
||||
//copydll
|
||||
|
||||
AddHotfixAddressableDll();
|
||||
//清空用户旧数据
|
||||
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
if (package.PackageName == BuildAssetWindow.GetBuildPackageName())
|
||||
{
|
||||
assetBundleCollectorPackage = package;
|
||||
}
|
||||
}
|
||||
|
||||
if (assetBundleCollectorPackage != null)
|
||||
{
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
|
||||
}
|
||||
|
||||
string configPath =
|
||||
$"Assets/Domain/{BuildAssetWindow.GetBuildPackageName()}/AddressableRes/Config/DomainConfig.asset";
|
||||
DomainConfig domainConfig =
|
||||
@@ -173,6 +165,23 @@ namespace Stary.Evo.Editor
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddRawFileMark()
|
||||
{
|
||||
AssetBundleCollectorPackage assetBundleCollectorPackage = null;
|
||||
var packageRawFile = $"{BuildAssetWindow.GetBuildPackageName()}_RawFile";
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
if (packageRawFile == BuildAssetWindow.GetBuildPackageName())
|
||||
{
|
||||
assetBundleCollectorPackage = package;
|
||||
}
|
||||
}
|
||||
|
||||
if (assetBundleCollectorPackage != null)
|
||||
{
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateRes(string domain, string resPath, string outputPath)
|
||||
{
|
||||
@@ -182,11 +191,6 @@ namespace Stary.Evo.Editor
|
||||
|
||||
#region 自动标记
|
||||
|
||||
private static Dictionary<string, string> addressDic = new Dictionary<string, string>();
|
||||
|
||||
private static Dictionary<string, AssetBundleCollectorGroup> _collectorGroupDic =
|
||||
new Dictionary<string, AssetBundleCollectorGroup>();
|
||||
|
||||
public static void Mark()
|
||||
{
|
||||
addressDic.Clear();
|
||||
@@ -196,39 +200,26 @@ namespace Stary.Evo.Editor
|
||||
string remotedRoot = $"{DomainRoot}/{_packageName}/AddressableRes";
|
||||
DirectoryInfo[] dirs = new DirectoryInfo(remotedRoot).GetDirectories();
|
||||
|
||||
var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
|
||||
setting.ShowPackageView = true;
|
||||
setting.UniqueBundleName = true;
|
||||
//创建Package文件
|
||||
package = YooAsset.Editor.AssetBundleCollectorSettingData.CreatePackage(_packageName);
|
||||
|
||||
//检测Packages是否存在TestPackage
|
||||
package.PackageName = _packageName;
|
||||
package.EnableAddressable = true;
|
||||
package.IncludeAssetGUID = true;
|
||||
package.AutoCollectShaders = true;
|
||||
package.IgnoreRuleName = "NormalIgnoreRule";
|
||||
|
||||
|
||||
package = CreatePackage(_packageName);
|
||||
packageRawFile = CreatePackage($"{_packageName}_RawFile");
|
||||
//检测Packages是否存在Group
|
||||
foreach (var info in dirs)
|
||||
{
|
||||
string groupName = info.Name;
|
||||
|
||||
if (info.Name != "Atlas")
|
||||
if (groupName.Equals("Atlas"))
|
||||
{
|
||||
AssetBundleCollectorGroup collectorGroup =
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
|
||||
collectorGroup.AssetTags = groupName;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_collectorGroupDic.ContainsKey(groupName))
|
||||
{
|
||||
_collectorGroupDic.Add(groupName, collectorGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("分组 : " + groupName + "已存在,请检查资源目录,避免重复");
|
||||
}
|
||||
if (rawFiles.Contains(groupName))
|
||||
{
|
||||
AddGroup(packageRawFile, groupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddGroup(package, groupName);
|
||||
}
|
||||
|
||||
AutoMarkRootAddress(info);
|
||||
@@ -240,7 +231,7 @@ namespace Stary.Evo.Editor
|
||||
///自动创建图集
|
||||
Debug.Log("开始创建图集");
|
||||
AutoCreateSpriteAtlas(remotedRoot);
|
||||
MarkStatus();
|
||||
DeleteMarkGroup();
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
|
||||
|
||||
// CreateRes();
|
||||
@@ -276,33 +267,35 @@ namespace Stary.Evo.Editor
|
||||
string groupName = dir.Name;
|
||||
string assetPath = FilesUtils.AbsoluteToRelativePath("Assets", file); //Asset到文件的路径
|
||||
var guid = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
var group = _collectorGroupDic[groupName];
|
||||
if (group != null)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector()
|
||||
{
|
||||
CollectPath = assetPath,
|
||||
CollectorGUID = guid,
|
||||
CollectorType = ECollectorType.MainAssetCollector,
|
||||
AddressRuleName = nameof(AddressByFolderAndFileName),
|
||||
AssetTags = groupName,
|
||||
};
|
||||
|
||||
//TODO 暂时不设置
|
||||
// 如果是video目录,设置
|
||||
// if (groupName == "Video")
|
||||
// {
|
||||
// collector.PackRuleName = nameof(PackVideoFile);
|
||||
// }
|
||||
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
|
||||
Debug.Log("GetAssetAddress:" + GetAssetAddress(file));
|
||||
AddAddressInfo(file, GetAssetAddress(file));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("分组 = " + groupName + "不存在");
|
||||
}
|
||||
AddCollector(groupName, guid, assetPath, file);
|
||||
// var group = _collectorGroupDic[groupName];
|
||||
// if (group != null)
|
||||
// {
|
||||
// AssetBundleCollector collector = new AssetBundleCollector()
|
||||
// {
|
||||
// CollectPath = assetPath,
|
||||
// CollectorGUID = guid,
|
||||
// CollectorType = ECollectorType.MainAssetCollector,
|
||||
// AddressRuleName = nameof(AddressByFolderAndFileName),
|
||||
// AssetTags = groupName,
|
||||
// };
|
||||
//
|
||||
// //TODO 暂时不设置
|
||||
// // 如果是video目录,设置
|
||||
// // if (groupName == "Video")
|
||||
// // {
|
||||
// // collector.PackRuleName = nameof(PackVideoFile);
|
||||
// // }
|
||||
//
|
||||
// YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
|
||||
// Debug.Log("GetAssetAddress:" + GetAssetAddress(file));
|
||||
// AddAddressInfo(file, GetAssetAddress(file));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError("分组 = " + groupName + "不存在");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -380,27 +373,27 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
|
||||
var guid = AssetDatabase.AssetPathToGUID(guidPath);
|
||||
|
||||
var group = _collectorGroupDic[groupname];
|
||||
if (group != null)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector()
|
||||
{
|
||||
CollectPath = guidPath,
|
||||
CollectorGUID = guid,
|
||||
CollectorType = ECollectorType.MainAssetCollector,
|
||||
AddressRuleName = nameof(AddressByFolderAndFileName),
|
||||
AssetTags = groupname,
|
||||
};
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
|
||||
|
||||
|
||||
AddAddressInfo(path, GetAssetAddress(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("分组 = " + GetAssetAddress(path) + "不存在");
|
||||
}
|
||||
AddCollector(groupname, guid, guidPath, path);
|
||||
// var group = _collectorGroupDic[groupname];
|
||||
// if (group != null)
|
||||
// {
|
||||
// AssetBundleCollector collector = new AssetBundleCollector()
|
||||
// {
|
||||
// CollectPath = guidPath,
|
||||
// CollectorGUID = guid,
|
||||
// CollectorType = ECollectorType.MainAssetCollector,
|
||||
// AddressRuleName = nameof(AddressByFolderAndFileName),
|
||||
// AssetTags = groupname,
|
||||
// };
|
||||
// YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
|
||||
//
|
||||
//
|
||||
// AddAddressInfo(path, GetAssetAddress(path));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError("分组 = " + GetAssetAddress(path) + "不存在");
|
||||
// }
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
@@ -418,6 +411,86 @@ namespace Stary.Evo.Editor
|
||||
|
||||
#endregion
|
||||
|
||||
private static AssetBundleCollectorPackage CreatePackage(string packageName)
|
||||
{
|
||||
var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
|
||||
setting.ShowPackageView = true;
|
||||
setting.UniqueBundleName = true;
|
||||
AssetBundleCollectorPackage assetBundleCollectorPackage = null;
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
{
|
||||
assetBundleCollectorPackage = package;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (assetBundleCollectorPackage != null)
|
||||
{
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
|
||||
}
|
||||
|
||||
//创建Package文件
|
||||
assetBundleCollectorPackage = YooAsset.Editor.AssetBundleCollectorSettingData.CreatePackage(packageName);
|
||||
|
||||
//检测Packages是否存在TestPackage
|
||||
assetBundleCollectorPackage.PackageName = packageName;
|
||||
assetBundleCollectorPackage.EnableAddressable = true;
|
||||
assetBundleCollectorPackage.IncludeAssetGUID = true;
|
||||
assetBundleCollectorPackage.AutoCollectShaders = true;
|
||||
assetBundleCollectorPackage.IgnoreRuleName = "NormalIgnoreRule";
|
||||
|
||||
return assetBundleCollectorPackage;
|
||||
}
|
||||
|
||||
private static void AddGroup(AssetBundleCollectorPackage package, string groupName)
|
||||
{
|
||||
AssetBundleCollectorGroup collectorGroup =
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
|
||||
collectorGroup.AssetTags = groupName;
|
||||
|
||||
if (!_collectorGroupDic.ContainsKey(groupName))
|
||||
{
|
||||
_collectorGroupDic.Add(groupName, collectorGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("分组 : " + groupName + "已存在,请检查资源目录,避免重复");
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddCollector(string groupName, string guid, string assetPath, string file)
|
||||
{
|
||||
var group = _collectorGroupDic[groupName];
|
||||
if (group != null)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector()
|
||||
{
|
||||
CollectPath = assetPath,
|
||||
CollectorGUID = guid,
|
||||
CollectorType = ECollectorType.MainAssetCollector,
|
||||
AddressRuleName = nameof(AddressByFolderAndFileName),
|
||||
AssetTags = groupName,
|
||||
};
|
||||
|
||||
////TODO 暂时不设置
|
||||
//如果是video目录,设置
|
||||
if (rawFiles.Contains(groupName))
|
||||
{
|
||||
collector.PackRuleName = nameof(PackVideoFile);
|
||||
}
|
||||
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
|
||||
Debug.Log("GetAssetAddress:" + GetAssetAddress(file));
|
||||
AddAddressInfo(file, GetAssetAddress(file));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("分组 = " + groupName + "不存在");
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddAddressInfo(string assetPath, string address)
|
||||
{
|
||||
if (addressDic.ContainsKey(assetPath))
|
||||
@@ -447,22 +520,22 @@ namespace Stary.Evo.Editor
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 标记为资源分组
|
||||
/// 删除资源为空的分组
|
||||
/// </summary>
|
||||
private static void MarkStatus()
|
||||
private static void DeleteMarkGroup()
|
||||
{
|
||||
List<AssetBundleCollectorGroup> deleteList = new List<AssetBundleCollectorGroup>();
|
||||
for (int i = 0; i < package.Groups.Count; i++)
|
||||
{
|
||||
var group = package.Groups[i];
|
||||
if (group.GroupName != "Default Local Group" && group.GroupName != "Built In Data")
|
||||
// if (group.GroupName != "Default Local Group" && group.GroupName != "Built In Data")
|
||||
// {
|
||||
if (group.Collectors.Count <= 0)
|
||||
{
|
||||
if (group.Collectors.Count <= 0)
|
||||
{
|
||||
///删除没有资源的分组
|
||||
deleteList.Add(group);
|
||||
}
|
||||
///删除没有资源的分组
|
||||
deleteList.Add(group);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
for (int i = 0; i < deleteList.Count; i++)
|
||||
@@ -471,6 +544,8 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
}
|
||||
|
||||
#region 收集shader变体
|
||||
|
||||
public static void CollectSvc(string root, string packageName, Action complete)
|
||||
{
|
||||
string remotedRoot = $"{root}/{packageName}/ShaderVariants";
|
||||
@@ -505,7 +580,6 @@ namespace Stary.Evo.Editor
|
||||
ShaderVariantCollector.Run(localSavePath, packageName, 1000, CompletedCallback);
|
||||
}
|
||||
|
||||
// 新增方法:创建独立的ShaderVariants分组(防止多个package冲突)
|
||||
private static void CreateShaderVariantsGroup(string packageName, string localSavePath)
|
||||
{
|
||||
string groupname = $"ShaderVariants_{packageName}";
|
||||
@@ -537,5 +611,7 @@ namespace Stary.Evo.Editor
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(collectorGroup, collector);
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -24,5 +24,7 @@ namespace Stary.Evo
|
||||
// /// 原生文件构建管线 (RFBP)
|
||||
// /// </summary>
|
||||
// RawFileBuildPipeline,
|
||||
|
||||
MixedBuildPipeline
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user