【m】修改核心框架
This commit is contained in:
@@ -122,9 +122,7 @@ namespace Stary.Evo.Editor
|
|||||||
|
|
||||||
#region BuildAsset
|
#region BuildAsset
|
||||||
|
|
||||||
[BoxGroup("Build", showLabel: false)]
|
[BoxGroup("Build", showLabel: false)] [InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)] [HideLabel]
|
||||||
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
|
|
||||||
[HideLabel]
|
|
||||||
public BuildAssetDataSetting BuildAssetDataSetting;
|
public BuildAssetDataSetting BuildAssetDataSetting;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -202,9 +200,7 @@ namespace Stary.Evo.Editor
|
|||||||
|
|
||||||
#region Update
|
#region Update
|
||||||
|
|
||||||
[BoxGroup("Build", showLabel: false)]
|
[BoxGroup("Build", showLabel: false)] [Title("打包本地资源", titleAlignment: TitleAlignments.Centered)] [HideLabel]
|
||||||
[Title("打包本地资源", titleAlignment: TitleAlignments.Centered)]
|
|
||||||
[HideLabel]
|
|
||||||
public BuildAssetEntity onBuildPipelineEntity;
|
public BuildAssetEntity onBuildPipelineEntity;
|
||||||
|
|
||||||
[BoxGroup("Build", showLabel: false)]
|
[BoxGroup("Build", showLabel: false)]
|
||||||
@@ -248,93 +244,99 @@ 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);
|
||||||
foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories))
|
// 新增:打包为zip的逻辑
|
||||||
{
|
string zipFileName =
|
||||||
// 获取文件在压缩包中的相对路径
|
$"{setting.packageName}_{setting.packageVersion}.zip";
|
||||||
string entryName =$"{setting.packageName}/{ Path.GetRelativePath(outFilePath, filePath)}";
|
//原yooAsset目录
|
||||||
// 创建zip条目
|
var outputPackageDirectory =
|
||||||
ZipArchiveEntry entry = archive.CreateEntry(entryName,
|
$"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}";
|
||||||
System.IO.Compression.CompressionLevel.Optimal);
|
//拷贝目录
|
||||||
|
string outFilePath = $"{outputPackageDirectory}/{setting.packageVersion}";
|
||||||
|
var copyPackageDirectory =
|
||||||
|
$"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}";
|
||||||
|
|
||||||
// 写入文件内容
|
//拷贝BuildinCatalog文件
|
||||||
using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
CreateBuildinCatalogFile("BuildinCatalog.json", copyPackageDirectory, outFilePath);
|
||||||
using (Stream entryStream = entry.Open())
|
CreateBuildinCatalogFile("BuildinCatalog.bytes", copyPackageDirectory, outFilePath);
|
||||||
{
|
|
||||||
fileStream.CopyTo(entryStream);
|
|
||||||
}
|
//RawFile目录路径
|
||||||
|
string outputRawFileDirectory = "", outRawFilePath = "", copyRawFilePackageDirectory = "";
|
||||||
|
outputRawFileDirectory =
|
||||||
|
$"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}_RawFile";
|
||||||
|
if (Directory.Exists(outputRawFileDirectory))
|
||||||
|
{
|
||||||
|
outRawFilePath = $"{outputRawFileDirectory}/{setting.packageVersion}";
|
||||||
|
copyRawFilePackageDirectory =
|
||||||
|
$"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}_RawFile";
|
||||||
|
CreateBuildinCatalogFile("BuildinCatalog.json", copyRawFilePackageDirectory, outRawFilePath);
|
||||||
|
CreateBuildinCatalogFile("BuildinCatalog.bytes", copyRawFilePackageDirectory, outRawFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打包RawFile文件
|
|
||||||
if (Directory.Exists(outRawFilePath))
|
//输出目录
|
||||||
|
string zipFilePath = Path.Combine(outputPackageDirectory, zipFileName);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
foreach (string filePath in Directory.GetFiles(outRawFilePath, "*.*", SearchOption.AllDirectories))
|
using (FileStream zipStream = new FileStream(zipFilePath, FileMode.Create))
|
||||||
|
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
|
||||||
{
|
{
|
||||||
// 获取文件在压缩包中的相对路径
|
// 打包主包文件
|
||||||
string entryName =$"{setting.packageName}_RawFile/{ Path.GetRelativePath(outRawFilePath, filePath)}";
|
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())
|
|
||||||
{
|
{
|
||||||
fileStream.CopyTo(entryStream);
|
// 获取文件在压缩包中的相对路径
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
fileStream.CopyTo(entryStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打包RawFile文件
|
||||||
|
if (Directory.Exists(outputRawFileDirectory) && Directory.Exists(outRawFilePath))
|
||||||
|
{
|
||||||
|
foreach (string filePath in Directory.GetFiles(outRawFilePath, "*.*",
|
||||||
|
SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
// 获取文件在压缩包中的相对路径
|
||||||
|
string entryName =
|
||||||
|
$"{setting.packageName}_RawFile/{Path.GetRelativePath(outRawFilePath, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
private static void CreateBuildinCatalogFile(string fileName, string copyPackageDirectory, string outFilePath)
|
||||||
{
|
{
|
||||||
@@ -355,8 +357,6 @@ namespace Stary.Evo.Editor
|
|||||||
|
|
||||||
public static async Task UpdateFileDataResDomain(BuildAssetDataSetting setting, string zipFilePath)
|
public static async Task UpdateFileDataResDomain(BuildAssetDataSetting setting, string zipFilePath)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
string ip = CustomEditorPrefs.GetString("ip");
|
string ip = CustomEditorPrefs.GetString("ip");
|
||||||
var messageEntity = await WebRequestSystem.PostFile(ip + "/FileLoad/UpLoadFile", new[] { zipFilePath });
|
var messageEntity = await WebRequestSystem.PostFile(ip + "/FileLoad/UpLoadFile", new[] { zipFilePath });
|
||||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(上传zip文件)", 0.5f);
|
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(上传zip文件)", 0.5f);
|
||||||
@@ -401,7 +401,6 @@ namespace Stary.Evo.Editor
|
|||||||
"确定");
|
"确定");
|
||||||
setting.GetBuildPackageVersion(true);
|
setting.GetBuildPackageVersion(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(更新数据库)", 1f);
|
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(更新数据库)", 1f);
|
||||||
@@ -428,7 +427,8 @@ namespace Stary.Evo.Editor
|
|||||||
DomainName = selectedPackageNames,
|
DomainName = selectedPackageNames,
|
||||||
Platform = EditorUserBuildSettings.activeBuildTarget.ToString(),
|
Platform = EditorUserBuildSettings.activeBuildTarget.ToString(),
|
||||||
};
|
};
|
||||||
var resResultMessage = await WebRequestSystem.Post(CustomEditorPrefs.GetString("ip") + "/ResDomain/GetResDomainByDomain",
|
var resResultMessage = await WebRequestSystem.Post(
|
||||||
|
CustomEditorPrefs.GetString("ip") + "/ResDomain/GetResDomainByDomain",
|
||||||
JsonConvert.SerializeObject(resDmainAddRequst));
|
JsonConvert.SerializeObject(resDmainAddRequst));
|
||||||
//如果低于服务器版本,更新版本号
|
//如果低于服务器版本,更新版本号
|
||||||
if (resResultMessage.code != 1011)
|
if (resResultMessage.code != 1011)
|
||||||
@@ -493,7 +493,6 @@ namespace Stary.Evo.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private bool IsRelease()
|
private bool IsRelease()
|
||||||
{
|
{
|
||||||
return BuildAssetDataSetting.environmentType == EnvironmentType.Release;
|
return BuildAssetDataSetting.environmentType == EnvironmentType.Release;
|
||||||
|
|||||||
+51
-29
@@ -27,6 +27,7 @@ namespace Stary.Evo.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 然后使用ScriptableBuildPipeline打包其余文件
|
// 2. 然后使用ScriptableBuildPipeline打包其余文件
|
||||||
|
|
||||||
Debug.Log("开始使用RawFileBuildPipeline打包视频文件...");
|
Debug.Log("开始使用RawFileBuildPipeline打包视频文件...");
|
||||||
var rawBuildResult = BuildRawFiles();
|
var rawBuildResult = BuildRawFiles();
|
||||||
if (!rawBuildResult.Success)
|
if (!rawBuildResult.Success)
|
||||||
@@ -34,6 +35,7 @@ namespace Stary.Evo.Editor
|
|||||||
Debug.LogError("视频文件打包失败!");
|
Debug.LogError("视频文件打包失败!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log("混合打包完成!");
|
Debug.Log("混合打包完成!");
|
||||||
base.ExecuteBuild();
|
base.ExecuteBuild();
|
||||||
}
|
}
|
||||||
@@ -41,35 +43,54 @@ namespace Stary.Evo.Editor
|
|||||||
private BuildResult BuildRawFiles()
|
private BuildResult BuildRawFiles()
|
||||||
{
|
{
|
||||||
var rawPackageName = $"{packageName}_RawFile";
|
var rawPackageName = $"{packageName}_RawFile";
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(packageName, selectedBuildPipelines);
|
var package = AssetBundleCollectorSettingData.Setting.GetPackage(rawPackageName);
|
||||||
var buildinFileCopyOption =
|
int count = 0;
|
||||||
AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(packageName, selectedBuildPipelines);
|
foreach (var group in package.Groups)
|
||||||
var buildinFileCopyParams =
|
{
|
||||||
AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(packageName, selectedBuildPipelines);
|
foreach (var collector in group.Collectors)
|
||||||
var clearBuildCache =
|
{
|
||||||
AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
|
count++;
|
||||||
var useAssetDependencyDB =
|
}
|
||||||
AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
|
}
|
||||||
|
if (count > 0)
|
||||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
{
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
var fileNameStyle =
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
AssetBundleBuilderSetting.GetPackageFileNameStyle(packageName, selectedBuildPipelines);
|
||||||
buildParameters.BuildPipeline = selectedBuildPipelines;
|
var buildinFileCopyOption =
|
||||||
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(packageName, selectedBuildPipelines);
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
var buildinFileCopyParams =
|
||||||
buildParameters.PackageName = rawPackageName;
|
AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(packageName, selectedBuildPipelines);
|
||||||
buildParameters.PackageVersion = packageVersion;
|
var clearBuildCache =
|
||||||
buildParameters.VerifyBuildingResult = true;
|
AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
var useAssetDependencyDB =
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
|
||||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
|
||||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
|
||||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
|
||||||
// SetVideoGroupActive(true);
|
|
||||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
|
||||||
return pipeline.Run(buildParameters, true);
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new BuildResult()
|
||||||
|
{
|
||||||
|
Success = false
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,7 +106,8 @@ namespace Stary.Evo.Editor
|
|||||||
var useAssetDependencyDB =
|
var useAssetDependencyDB =
|
||||||
AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
|
AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
|
||||||
|
|
||||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
|
var clearBuildCache =
|
||||||
|
AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
|
||||||
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
||||||
|
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||||
|
|||||||
@@ -165,24 +165,6 @@ 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)
|
private static void CreateRes(string domain, string resPath, string outputPath)
|
||||||
{
|
{
|
||||||
ResFileGet.CreateClass(addressDic, "Res", domain, outputPath,
|
ResFileGet.CreateClass(addressDic, "Res", domain, outputPath,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace Stary.Evo
|
|||||||
public class AppConfig
|
public class AppConfig
|
||||||
{
|
{
|
||||||
public static OpenDomainType OpenDomainType { get; set; }
|
public static OpenDomainType OpenDomainType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// package name
|
/// package name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -26,6 +27,15 @@ namespace Stary.Evo
|
|||||||
private static GameObject _MainBaseModel;
|
private static GameObject _MainBaseModel;
|
||||||
|
|
||||||
|
|
||||||
|
public static bool DeveloperMode
|
||||||
|
{
|
||||||
|
get { return HybridClREntrance.Global.stage == StageType.Developer || PackageDomainName == "Main"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool MainPackageMode
|
||||||
|
{
|
||||||
|
get { return PackageDomainName == "Main"; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 赋值默认的实例
|
/// 赋值默认的实例
|
||||||
@@ -48,6 +58,8 @@ namespace Stary.Evo
|
|||||||
{
|
{
|
||||||
public const string RikidHandLeft = "LeftHandRender/RKHandVisual/Hand_L/left_wrist/left_palm";
|
public const string RikidHandLeft = "LeftHandRender/RKHandVisual/Hand_L/left_wrist/left_palm";
|
||||||
public const string RikidHandRight = "RightHandRender/RKHandVisual/Hand_R/right_wrist/right_palm";
|
public const string RikidHandRight = "RightHandRender/RKHandVisual/Hand_R/right_wrist/right_palm";
|
||||||
public const string RikidHandRightIndexTip = "RightHandRender/RKHandVisual/Hand_R/right_wrist/right_index_metacarpal/right_index_proximal/right_index_intermediate/right_index_distal/right_index_tip";
|
|
||||||
|
public const string RikidHandRightIndexTip =
|
||||||
|
"RightHandRender/RKHandVisual/Hand_R/right_wrist/right_index_metacarpal/right_index_proximal/right_index_intermediate/right_index_distal/right_index_tip";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,21 +129,28 @@ namespace Stary.Evo
|
|||||||
{
|
{
|
||||||
var initParams = YooAssetFileSystem.HostInitializeParameter(package.PackageName);
|
var initParams = YooAssetFileSystem.HostInitializeParameter(package.PackageName);
|
||||||
// initParameters.CacheFileSystemParameters = cacheFileSystemParams;
|
// initParameters.CacheFileSystemParameters = cacheFileSystemParams;
|
||||||
|
try
|
||||||
var initOperation = package.InitializeAsync(initParams);
|
|
||||||
|
|
||||||
await initOperation;
|
|
||||||
|
|
||||||
if (initOperation.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
{
|
||||||
Debug.Log("UnityEvo:从远程加载资源包,初始化成功!");
|
var initOperation = package.InitializeAsync(initParams);
|
||||||
return true;
|
|
||||||
|
await initOperation;
|
||||||
|
|
||||||
|
if (initOperation.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
Debug.Log("UnityEvo:从远程加载资源包,初始化成功!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"UnityEvo:从远程加载资源包,初始化失败:{initOperation.Error}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogError($"UnityEvo:从远程加载资源包,初始化失败:{initOperation.Error}");
|
Debug.LogError($"UnityEvo:从远程加载资源包,初始化失败:{e}");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async UniTask OFFLINE_PLAYMODE(ResourcePackage package)
|
private async UniTask OFFLINE_PLAYMODE(ResourcePackage package)
|
||||||
@@ -156,19 +163,26 @@ namespace Stary.Evo
|
|||||||
{
|
{
|
||||||
//Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
|
//Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
|
||||||
var initParams = YooAssetFileSystem.HostInitializeParameter(package.PackageName);
|
var initParams = YooAssetFileSystem.HostInitializeParameter(package.PackageName);
|
||||||
var initOperation = package.InitializeAsync(initParams);
|
try
|
||||||
await initOperation;
|
|
||||||
if (initOperation.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
{
|
||||||
Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
|
var initOperation = package.InitializeAsync(initParams);
|
||||||
return true;
|
await initOperation;
|
||||||
|
if (initOperation.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
|
Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{e}");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
var operation = package.RequestPackageVersionAsync();
|
var operation = package.RequestPackageVersionAsync();
|
||||||
await operation;
|
await operation;
|
||||||
@@ -321,7 +335,7 @@ namespace Stary.Evo
|
|||||||
{
|
{
|
||||||
//初始化读取资源配置表
|
//初始化读取资源配置表
|
||||||
var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
|
var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
|
||||||
if (AppConfig.PackageDomainName.Equals("Main") ||HybridClREntrance.Global.stage == StageType.Developer)
|
if (AppConfig.PackageDomainName.Equals("Main") || HybridClREntrance.Global.stage == StageType.Developer)
|
||||||
{
|
{
|
||||||
//加载热更配置文件
|
//加载热更配置文件
|
||||||
var loadHotfixSettingsOp = package.LoadAssetAsync<DomainConfig>("Config_DomainConfig");
|
var loadHotfixSettingsOp = package.LoadAssetAsync<DomainConfig>("Config_DomainConfig");
|
||||||
@@ -380,12 +394,12 @@ namespace Stary.Evo
|
|||||||
//string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent", AppConfig.PackageDomainName);
|
//string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent", AppConfig.PackageDomainName);
|
||||||
string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent");
|
string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent");
|
||||||
//string loadPath = $"{Application.persistentDataPath}/DownloadedContent/{AppConfig.PackageDomainName}";
|
//string loadPath = $"{Application.persistentDataPath}/DownloadedContent/{AppConfig.PackageDomainName}";
|
||||||
if (Directory.Exists(loadPath))
|
// if (Directory.Exists(loadPath))
|
||||||
{
|
// {
|
||||||
Directory.Delete(loadPath, true);
|
// Directory.Delete(loadPath, true);
|
||||||
// 等一帧,让系统真正释放句柄
|
// // 等一帧,让系统真正释放句柄
|
||||||
await UniTask.DelayFrame(1);
|
// await UniTask.DelayFrame(1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
|
FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
|
||||||
if (loadSystem != null && loadSystem.ProgressBarPanel == null)
|
if (loadSystem != null && loadSystem.ProgressBarPanel == null)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace Stary.Evo
|
|||||||
//4.下载补丁包
|
//4.下载补丁包
|
||||||
await Download();
|
await Download();
|
||||||
|
|
||||||
if (HybridClREntrance.Global.stage == StageType.Developer)
|
if (AppConfig.DeveloperMode)
|
||||||
{
|
{
|
||||||
//加载热更配置文件
|
//加载热更配置文件
|
||||||
var loadHotfixSettingsOp = package.LoadAssetAsync<DomainConfig>("Config_DomainConfig");
|
var loadHotfixSettingsOp = package.LoadAssetAsync<DomainConfig>("Config_DomainConfig");
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Stary.Evo
|
|||||||
private DomainConfig.LoadResType loadResType;
|
private DomainConfig.LoadResType loadResType;
|
||||||
public GameObject mainPrefab;
|
public GameObject mainPrefab;
|
||||||
private DomainConfig domainConfig;
|
private DomainConfig domainConfig;
|
||||||
|
private string _packageName;
|
||||||
private string _sceneName;
|
private string _sceneName;
|
||||||
|
|
||||||
public ResStartState(IFsmSystemAsync system) : base(system)
|
public ResStartState(IFsmSystemAsync system) : base(system)
|
||||||
@@ -37,93 +37,100 @@ namespace Stary.Evo
|
|||||||
|
|
||||||
public override async UniTask OnEnterAsync<T1, T2>(T1 param1, T2 param2)
|
public override async UniTask OnEnterAsync<T1, T2>(T1 param1, T2 param2)
|
||||||
{
|
{
|
||||||
if (domainConfig == null && HybridClREntrance.Global.stage == StageType.Originality)
|
if (AppConfig.DeveloperMode)
|
||||||
return;
|
|
||||||
domainConfig = param1 as DomainConfig;
|
|
||||||
loadResType = domainConfig.loadResType;
|
|
||||||
Type type = param2 as Type;
|
|
||||||
var package = YooAssets.GetPackage(domainConfig.domain);
|
|
||||||
switch (loadResType)
|
|
||||||
{
|
{
|
||||||
case DomainConfig.LoadResType.Prefab:
|
domainConfig = param1 as DomainConfig;
|
||||||
|
loadResType = domainConfig.loadResType;
|
||||||
await LoadDomainPrefab(package);
|
_packageName = domainConfig.domain;
|
||||||
|
Type type = param2 as Type;
|
||||||
break;
|
var package = YooAssets.GetPackage(domainConfig.domain);
|
||||||
case DomainConfig.LoadResType.Scene:
|
switch (loadResType)
|
||||||
|
|
||||||
var sceneMode = domainConfig.loadSceneMode;
|
|
||||||
var physicsMode = LocalPhysicsMode.None;
|
|
||||||
SceneHandle handle = package.LoadSceneAsync(domainConfig.sceneIdentifier, sceneMode, physicsMode);
|
|
||||||
await handle;
|
|
||||||
|
|
||||||
Scene targetScene = SceneManager.GetSceneByName(handle.SceneName);
|
|
||||||
// targetScene.name = domainConfig.mainScene;
|
|
||||||
// 设置为 active scene 或者后续 Move 到该 scene
|
|
||||||
SceneManager.SetActiveScene(targetScene);
|
|
||||||
_sceneName = targetScene.name;
|
|
||||||
mainPrefab = GameObject.Find(domainConfig.mainPrefab);
|
|
||||||
if (mainPrefab == null)
|
|
||||||
{
|
|
||||||
await LoadDomainPrefab(package);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (domainConfig.domain != "Main")
|
|
||||||
{
|
|
||||||
LocalTransformInfo info = mainPrefab.GetOrAddComponent<LocalTransformInfo>();
|
|
||||||
FsmLoadSystem fsmLoadSystem = FsmSystem as FsmLoadSystem;
|
|
||||||
|
|
||||||
if (info._list.Count >= 2)
|
|
||||||
{
|
{
|
||||||
if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.PointCloud)
|
case DomainConfig.LoadResType.Prefab:
|
||||||
|
|
||||||
|
await LoadDomainPrefab(package);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case DomainConfig.LoadResType.Scene:
|
||||||
|
|
||||||
|
var sceneMode = domainConfig.loadSceneMode;
|
||||||
|
var physicsMode = LocalPhysicsMode.None;
|
||||||
|
SceneHandle handle =
|
||||||
|
package.LoadSceneAsync(domainConfig.sceneIdentifier, sceneMode, physicsMode);
|
||||||
|
await handle;
|
||||||
|
|
||||||
|
Scene targetScene = SceneManager.GetSceneByName(handle.SceneName);
|
||||||
|
// targetScene.name = domainConfig.mainScene;
|
||||||
|
// 设置为 active scene 或者后续 Move 到该 scene
|
||||||
|
SceneManager.SetActiveScene(targetScene);
|
||||||
|
_sceneName = targetScene.name;
|
||||||
|
mainPrefab = GameObject.Find(domainConfig.mainPrefab);
|
||||||
|
if (mainPrefab == null)
|
||||||
|
{
|
||||||
|
await LoadDomainPrefab(package);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (domainConfig.domain != "Main")
|
||||||
|
{
|
||||||
|
LocalTransformInfo info = mainPrefab.GetOrAddComponent<LocalTransformInfo>();
|
||||||
|
FsmLoadSystem fsmLoadSystem = FsmSystem as FsmLoadSystem;
|
||||||
|
|
||||||
|
if (info._list.Count >= 2)
|
||||||
{
|
{
|
||||||
info.Switch(1);
|
if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.PointCloud)
|
||||||
}
|
{
|
||||||
else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.VIOICE)
|
info.Switch(1);
|
||||||
{
|
}
|
||||||
info.Switch(0);
|
else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.VIOICE)
|
||||||
}
|
{
|
||||||
else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.ImageTracked)
|
info.Switch(0);
|
||||||
{
|
}
|
||||||
info.transform.position = fsmLoadSystem.GetTransformCtor().position;
|
else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.ImageTracked)
|
||||||
info.transform.rotation = Quaternion.Euler(fsmLoadSystem.GetTransformCtor().rotation);
|
{
|
||||||
info.transform.localScale = fsmLoadSystem.GetTransformCtor().scale;
|
info.transform.position = fsmLoadSystem.GetTransformCtor().position;
|
||||||
|
info.transform.rotation = Quaternion.Euler(fsmLoadSystem.GetTransformCtor().rotation);
|
||||||
|
info.transform.localScale = fsmLoadSystem.GetTransformCtor().scale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info.Switch(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info.Switch(0);
|
Debug.LogError($"UnityEvo:{mainPrefab.name}的TransformInfo长度小于2,无法继续运行,请排查");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (mainPrefab != null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"UnityEvo:{mainPrefab.name}的TransformInfo长度小于2,无法继续运行,请排查");
|
DomainBase hotfixInstance = mainPrefab.GetComponent(type) as DomainBase;
|
||||||
|
if (hotfixInstance == null)
|
||||||
|
{
|
||||||
|
hotfixInstance = mainPrefab.AddComponent(type) as DomainBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hotfixInstance == null)
|
||||||
|
{
|
||||||
|
Debug.LogError($"热更类{type.Name}实例创建失败!必须继承MonoBehaviour");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hotfixInstance.DomainName = domainConfig.domain;
|
||||||
|
hotfixInstance.DomainNameRaw = $"{domainConfig.domain}_RawFile";
|
||||||
|
|
||||||
|
|
||||||
|
// 原有调用逻辑修改为使用实例
|
||||||
|
hotfixInstance.OnEnter("");
|
||||||
|
hotfixInstance.OnEnterAsync("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (mainPrefab != null)
|
|
||||||
{
|
{
|
||||||
DomainBase hotfixInstance = mainPrefab.GetComponent(type) as DomainBase;
|
_packageName = AppConfig.PackageDomainName;
|
||||||
if (hotfixInstance == null)
|
|
||||||
{
|
|
||||||
hotfixInstance = mainPrefab.AddComponent(type) as DomainBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hotfixInstance == null)
|
|
||||||
{
|
|
||||||
Debug.LogError($"热更类{type.Name}实例创建失败!必须继承MonoBehaviour");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hotfixInstance.DomainName = domainConfig.domain;
|
|
||||||
hotfixInstance.DomainNameRaw = $"{domainConfig.domain}_RawFile";
|
|
||||||
|
|
||||||
|
|
||||||
// 原有调用逻辑修改为使用实例
|
|
||||||
hotfixInstance.OnEnter("");
|
|
||||||
hotfixInstance.OnEnterAsync("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,40 +163,39 @@ namespace Stary.Evo
|
|||||||
|
|
||||||
public override async UniTask OnExitAsync()
|
public override async UniTask OnExitAsync()
|
||||||
{
|
{
|
||||||
Debug.Log("UnityEvo:Domain退出...");
|
if (_packageName=="Main")
|
||||||
|
return;
|
||||||
|
|
||||||
if (HybridClREntrance.Global.stage == StageType.Developer)
|
if (HybridClREntrance.Global.stage == StageType.Developer)
|
||||||
{
|
{
|
||||||
if (domainConfig.domain != "Main")
|
DomainBase domainBase = mainPrefab.GetOrAddComponent<DomainBase>();
|
||||||
|
if (domainBase == null)
|
||||||
{
|
{
|
||||||
DomainBase domainBase = mainPrefab.GetOrAddComponent<DomainBase>();
|
Debug.LogError($"UnityEvo:{mainPrefab.name}的DomainBase为空,无法退出,请排查");
|
||||||
if (domainBase == null)
|
}
|
||||||
{
|
else
|
||||||
Debug.LogError($"UnityEvo:{mainPrefab.name}的DomainBase为空,无法退出,请排查");
|
{
|
||||||
}
|
domainBase.OnExit();
|
||||||
else
|
await domainBase.OnExitAsync();
|
||||||
{
|
|
||||||
domainBase.OnExit();
|
|
||||||
await domainBase.OnExitAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (domainBase != null)
|
GameObject.Destroy(domainBase.gameObject);
|
||||||
{
|
|
||||||
GameObject.Destroy(domainBase.gameObject);
|
|
||||||
|
|
||||||
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainName);
|
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainName);
|
||||||
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainNameRaw);
|
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainNameRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadResType == DomainConfig.LoadResType.Scene)
|
Debug.Log("UnityEvo:Domain退出...");
|
||||||
{
|
|
||||||
await SceneManager.UnloadSceneAsync(_sceneName);
|
if (loadResType == DomainConfig.LoadResType.Scene)
|
||||||
}
|
{
|
||||||
|
await SceneManager.UnloadSceneAsync(_sceneName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (HybridClREntrance.Global.stage == StageType.Originality)
|
else if (HybridClREntrance.Global.stage == StageType.Originality)
|
||||||
{
|
{
|
||||||
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(AppConfig.PackageDomainName);
|
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(_packageName);
|
||||||
AppConfig.PackageDomainName = "";
|
AppConfig.PackageDomainName = "";
|
||||||
|
Debug.Log("UnityEvo:Domain退出...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.tools",
|
"name": "com.staryevo.tools",
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"displayName": "00.StaryEvo.Tools",
|
"displayName": "00.StaryEvo.Tools",
|
||||||
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user