【m】优化加载架构
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ArtServerManageWindow : OdinEditorWindow
|
||||
{
|
||||
[MenuItem("Evo/Art/服务器数据管理工具", false, 2)]
|
||||
[MenuItem("Evo/Art/服务器数据管理工具", false, 1)]
|
||||
static void Init()
|
||||
{
|
||||
// Get existing open window or if none, make a new one:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.buildoriginality",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"displayName": "00.StaryEvo.BuildOriginality",
|
||||
"description": "美术打包工具",
|
||||
"unity": "2021.3",
|
||||
|
||||
@@ -166,9 +166,10 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
buildAssetDataSetting.environmentType = EnvironmentType.Release;
|
||||
buildAssetDataSetting.SetEnvironmentType();
|
||||
buildAssetDataSetting.viewer = new BuiltinBuildPipelineViewer(buildAssetDataSetting.packageName,
|
||||
buildAssetDataSetting.selectedBuildPipelines.ToString(),
|
||||
buildAssetDataSetting.packageVersion);
|
||||
buildAssetDataSetting.SetBuildPipelines();
|
||||
// buildAssetDataSetting.viewer = new ScriptableBuildPipelineViewer(buildAssetDataSetting.packageName,
|
||||
// buildAssetDataSetting.GetBuildPipelines().ToString(),
|
||||
// buildAssetDataSetting.packageVersion);
|
||||
buildAssetDataSetting.viewer.clearBuildCacheToggle = true;
|
||||
buildAssetDataSetting.viewer.SetBuildCacheToggle();
|
||||
EditorApplication.delayCall += buildAssetDataSetting.viewer.ExecuteBuild;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
int id = EditorUtility.DisplayDialogComplex("提示",
|
||||
$"当前为[{PLayerMode.EDITOR_SIMULATEMODE}]模式,请选择切换得热更模式!",
|
||||
$"{PLayerMode.HOST_PLAYMODE}", $"{PLayerMode.OFFLINE_PLAYMODE}", "取消");
|
||||
$"{PLayerMode.HOST_PLAYMODE}", $"{PLayerMode.HOST_PLAYMODE}", "取消");
|
||||
|
||||
switch (id)
|
||||
{
|
||||
@@ -30,8 +30,8 @@ namespace Stary.Evo.Editor
|
||||
Debug.Log("切换为[HOST_PLAYMODE]模式");
|
||||
break;
|
||||
case 1:
|
||||
ChangePlayerSchema.SetPlayerMode(PLayerMode.OFFLINE_PLAYMODE);
|
||||
Debug.Log("切换为[OFFLINE_PLAYMODE]模式");
|
||||
ChangePlayerSchema.SetPlayerMode(PLayerMode.HOST_PLAYMODE);
|
||||
Debug.Log("切换为[HOST_PLAYMODE]模式");
|
||||
break;
|
||||
case 2:
|
||||
|
||||
|
||||
@@ -13,10 +13,12 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
public void OnEnable()
|
||||
{
|
||||
BuildPipelineViewer();
|
||||
viewer = new ScriptableBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(),
|
||||
packageVersion);
|
||||
oldVersionX = packageVersionX;
|
||||
oldVersionY = packageVersionY;
|
||||
oldVersionZ = packageVersionZ;
|
||||
|
||||
}
|
||||
|
||||
[HideInInspector] public string packageName;
|
||||
@@ -32,10 +34,10 @@ namespace Stary.Evo.Editor
|
||||
[OnValueChanged("SetEnvironmentType")]
|
||||
public EnvironmentType environmentType;
|
||||
|
||||
[Title("构建列表", titleAlignment: TitleAlignments.Centered)]
|
||||
[HorizontalGroup("BuildSetting"), HideLabel]
|
||||
[OnValueChanged("SetBuildPipelines")]
|
||||
public EBuildPipeline selectedBuildPipelines;
|
||||
// [Title("构建列表", titleAlignment: TitleAlignments.Centered)]
|
||||
// [HorizontalGroup("BuildSetting"), HideLabel]
|
||||
// [OnValueChanged("SetBuildPipelines")]
|
||||
private BuildPipelineType selectedBuildPipelines = BuildPipelineType.ScriptableBuildPipeline;
|
||||
|
||||
private const string VerSersionMessage = "(小版本由打包叠加,中版本、大版本更新会重置小版本,如误操作,点击重置按钮即可)";
|
||||
|
||||
@@ -66,7 +68,8 @@ namespace Stary.Evo.Editor
|
||||
packageVersionY++;
|
||||
if (packageVersionZ > 0)
|
||||
packageVersionZ = 0;
|
||||
}else if (VersionType == VersionPosType.Z)
|
||||
}
|
||||
else if (VersionType == VersionPosType.Z)
|
||||
{
|
||||
packageVersionZ++;
|
||||
}
|
||||
@@ -90,7 +93,8 @@ namespace Stary.Evo.Editor
|
||||
packageVersionY--;
|
||||
if (packageVersionZ > 0)
|
||||
packageVersionZ = 0;
|
||||
}else if (VersionType == VersionPosType.Z)
|
||||
}
|
||||
else if (VersionType == VersionPosType.Z)
|
||||
{
|
||||
packageVersionZ--;
|
||||
if (packageVersionZ < 0)
|
||||
@@ -100,6 +104,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
GetPackageVersion();
|
||||
}
|
||||
|
||||
[Title("重置版本", titleAlignment: TitleAlignments.Centered)]
|
||||
[HorizontalGroup("BuildSetting/PackageVersion"), HideLabel, Button(Icon = SdfIconType.ArrowRepeat)]
|
||||
[HideIf("environmentType", EnvironmentType.Debug)]
|
||||
@@ -111,11 +116,9 @@ namespace Stary.Evo.Editor
|
||||
GetPackageVersion();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HideLabel] public AbstractBuildPipelineViewer viewer;
|
||||
|
||||
[HideLabel] private Dictionary<EBuildPipeline, AbstractBuildPipelineViewer> _viewers;
|
||||
//[HideLabel] private Dictionary<BuildPipelineType, AbstractBuildPipelineViewer> _viewers;
|
||||
|
||||
public void SetEnvironmentType()
|
||||
{
|
||||
@@ -141,9 +144,9 @@ namespace Stary.Evo.Editor
|
||||
packageVersionZ++;
|
||||
|
||||
packageVersion = $"{packageVersionX}.{packageVersionY}.{packageVersionZ}";
|
||||
|
||||
}
|
||||
BuildPipelineViewer();
|
||||
|
||||
//BuildPipelineViewer();
|
||||
EditorUtility.SetDirty(this);
|
||||
AssetDatabase.SaveAssets();
|
||||
return version;
|
||||
@@ -151,18 +154,16 @@ namespace Stary.Evo.Editor
|
||||
|
||||
public void GetPackageVersion()
|
||||
{
|
||||
SetBuildPipelines();
|
||||
if (environmentType == EnvironmentType.Debug)
|
||||
{
|
||||
viewer.clearBuildCacheToggle = true;
|
||||
selectedBuildPipelines = EBuildPipeline.EditorSimulateBuildPipeline;
|
||||
//selectedBuildPipelines = BuildPipelineType.EditorSimulateBuildPipeline;
|
||||
packageVersion = "Simulate";
|
||||
|
||||
}
|
||||
else if (environmentType == EnvironmentType.Release)
|
||||
{
|
||||
viewer.clearBuildCacheToggle = false;
|
||||
selectedBuildPipelines = EBuildPipeline.ScriptableBuildPipeline;
|
||||
//selectedBuildPipelines = BuildPipelineType.ScriptableBuildPipeline;
|
||||
|
||||
packageVersionX = packageVersionX > 1 ? packageVersionX : 1;
|
||||
packageVersionY =
|
||||
@@ -183,44 +184,62 @@ namespace Stary.Evo.Editor
|
||||
/// 设置当前构建管线
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private void SetBuildPipelines()
|
||||
public void SetBuildPipelines()
|
||||
{
|
||||
BuildPipelineViewer();
|
||||
if (packageName.IsNullOrEmpty())
|
||||
{
|
||||
packageName = BuildAssetWindow.GetBuildPackageName();
|
||||
}
|
||||
|
||||
// BuildPipelineViewer();
|
||||
|
||||
|
||||
if (viewer != null)
|
||||
viewer.SetBuildPackageData(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:BuildPipelineViewer 为空!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成打包实例
|
||||
/// 获取当前构建管线名称
|
||||
/// </summary>
|
||||
public void BuildPipelineViewer()
|
||||
/// <returns></returns>
|
||||
public BuildPipelineType GetBuildPipelinesName()
|
||||
{
|
||||
if (_viewers == null)
|
||||
_viewers = new Dictionary<EBuildPipeline, AbstractBuildPipelineViewer>();
|
||||
if (_viewers.ContainsKey(selectedBuildPipelines))
|
||||
{
|
||||
viewer = _viewers[selectedBuildPipelines];
|
||||
viewer.SetBuildPackageData(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (selectedBuildPipelines)
|
||||
{
|
||||
case EBuildPipeline.EditorSimulateBuildPipeline:
|
||||
viewer = new SimulateBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
break;
|
||||
case EBuildPipeline.BuiltinBuildPipeline:
|
||||
viewer = new BuiltinBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
break;
|
||||
case EBuildPipeline.ScriptableBuildPipeline:
|
||||
viewer = new ScriptableBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
break;
|
||||
case EBuildPipeline.RawFileBuildPipeline:
|
||||
viewer = new RawfileBuildpipelineViewer(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
break;
|
||||
}
|
||||
|
||||
_viewers.Add(selectedBuildPipelines, viewer);
|
||||
}
|
||||
return selectedBuildPipelines;
|
||||
}
|
||||
// /// <summary>
|
||||
// /// 生成打包实例
|
||||
// /// </summary>
|
||||
// public void BuildPipelineViewer()
|
||||
// {
|
||||
// if (_viewers == null)
|
||||
// _viewers = new Dictionary<BuildPipelineType, AbstractBuildPipelineViewer>();
|
||||
// if (_viewers.ContainsKey(selectedBuildPipelines))
|
||||
// {
|
||||
// viewer = _viewers[selectedBuildPipelines];
|
||||
// viewer.SetBuildPackageData(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// switch (selectedBuildPipelines)
|
||||
// {
|
||||
// case BuildPipelineType.EditorSimulateBuildPipeline:
|
||||
// viewer = new SimulateBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
// break;
|
||||
// case BuildPipelineType.ScriptableBuildPipeline:
|
||||
// viewer = new ScriptableBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
// break;
|
||||
// case BuildPipelineType.RawFileBuildPipeline:
|
||||
// viewer = new RawfileBuildpipelineViewer(packageName, selectedBuildPipelines.ToString(), packageVersion);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// _viewers.Add(selectedBuildPipelines, viewer);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public enum VersionPosType
|
||||
|
||||
@@ -216,7 +216,8 @@ namespace Stary.Evo.Editor
|
||||
|
||||
private void OnBuildPipeline()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{selectedPackageNames}]!", "Yes", "No"))
|
||||
if (EditorUtility.DisplayDialog("提示",
|
||||
$"开始构建资源包[{selectedPackageNames}],版本号为[{BuildAssetDataSetting.packageVersion}]!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += BuildAssetDataSetting.viewer.ExecuteBuild;
|
||||
@@ -229,7 +230,8 @@ namespace Stary.Evo.Editor
|
||||
|
||||
private async void OnUpdateBuildPipeline()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始上传至服务器[{selectedPackageNames}]!", "Yes", "No"))
|
||||
if (EditorUtility.DisplayDialog("提示",
|
||||
$"开始上传至服务器[{selectedPackageNames}],,版本号为[{BuildAssetDataSetting.packageVersion}", "Yes", "No"))
|
||||
{
|
||||
// 新增:打包为zip的逻辑
|
||||
string zipFilePath = BuildZip(BuildAssetDataSetting);
|
||||
@@ -373,10 +375,16 @@ namespace Stary.Evo.Editor
|
||||
EditorUtility.DisplayDialog("提示",
|
||||
$"{resResultMessage.message + $"\n{resResultMessage.data.ToString()}"}", "确定");
|
||||
}
|
||||
|
||||
else if (resResultMessage.code == 200)
|
||||
{
|
||||
EditorUtility.DisplayDialog("提示",
|
||||
$"上传成功,已更新为{setting.packageVersion}",
|
||||
"确定");
|
||||
setting.GetBuildPackageVersion(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(更新数据库)", 1f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
using YooAsset.Editor;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class BuiltinBuildPipelineViewer : AbstractBuildPipelineViewer
|
||||
{
|
||||
public BuiltinBuildPipelineViewer(string packageName, string selectedBuildPipelines, string packageVersion) :
|
||||
base(packageName, selectedBuildPipelines, packageVersion)
|
||||
{
|
||||
// isSimulate = false;
|
||||
}
|
||||
|
||||
public override void ExecuteBuild()
|
||||
{
|
||||
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 clearBuildCache =
|
||||
AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
|
||||
var useAssetDependencyDB =
|
||||
AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
|
||||
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = selectedBuildPipelines.ToString();
|
||||
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.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
Debug.Log($"Build Success! 【{buildResult.OutputPackageDirectory}】");
|
||||
//EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
base.ExecuteBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac3d61d6f0744f02a2f038fdeed98b75
|
||||
timeCreated: 1741830306
|
||||
@@ -34,7 +34,7 @@ namespace Stary.Evo.Editor
|
||||
Menu.SetChecked(EditorNotUpdateMode, platform == HotUpdateMode.NotUpdate.ToString());
|
||||
Menu.SetChecked(EditorHotUpdateMode, platform == HotUpdateMode.HotUpdate.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
|
||||
Debug.LogError("ChangeHotUpdateSchema");
|
||||
Debug.LogError("ChangeHotUpdateSchema:"+platform);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,31 +16,25 @@ namespace Stary.Evo.Editor
|
||||
private static PLayerMode _pLayerMode;
|
||||
|
||||
private const string EditorSimulateMode = "Evo/Schema/ChangePlayer/EditorSimulateMode(编辑器调试模式)";
|
||||
private const string OfflinePlayMode = "Evo/Schema/ChangePlayer/OfflinePlayMode(本地运行模式)";
|
||||
private const string HostPlayMode = "Evo/Schema/ChangePlayer/HostPlayMode(服务器运行模式)";
|
||||
private const string HostPlayMode = "Evo/Schema/ChangePlayer/HostPlayMode(联机运行模式)";
|
||||
private const string WebPlayMode = "Evo/Schema/ChangePlayer/WebPlayMode(Web运行模式)";
|
||||
|
||||
[MenuItem(EditorSimulateMode)]
|
||||
[MenuItem(EditorSimulateMode, false,3)]
|
||||
private static void SetEditorMode() => SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
|
||||
|
||||
[MenuItem(OfflinePlayMode)]
|
||||
private static void SetOfflineMode() => SetPlayerMode(PLayerMode.OFFLINE_PLAYMODE);
|
||||
|
||||
[MenuItem(HostPlayMode)]
|
||||
[MenuItem(HostPlayMode, false,3)]
|
||||
private static void SetHostMode() => SetPlayerMode(PLayerMode.HOST_PLAYMODE);
|
||||
|
||||
// [MenuItem(WebPlayMode)]
|
||||
// private static void SetWebMode() => SetPlayerMode(PLayerMode.WEB_PLAYMODE);
|
||||
|
||||
[MenuItem(EditorSimulateMode, true)]
|
||||
[MenuItem(EditorSimulateMode, true,3)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
string platform = EditorPrefs.GetString("ChangePlayerSchema");
|
||||
Menu.SetChecked(EditorSimulateMode, platform == PLayerMode.EDITOR_SIMULATEMODE.ToString());
|
||||
Menu.SetChecked(OfflinePlayMode, platform == PLayerMode.OFFLINE_PLAYMODE.ToString());
|
||||
Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString());
|
||||
Debug.LogError("CheckPlatform");
|
||||
Debug.LogError($"ChangePlayerSchema:{platform}");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,9 +72,6 @@ namespace Stary.Evo.Editor
|
||||
//编辑仿真模式,
|
||||
EDITOR_SIMULATEMODE,
|
||||
|
||||
//单机运行模式
|
||||
OFFLINE_PLAYMODE,
|
||||
|
||||
//联机运行模式
|
||||
HOST_PLAYMODE,
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9224eefce894279bc45f0e44c5eeb94
|
||||
timeCreated: 1767593352
|
||||
@@ -11,7 +11,7 @@ namespace Stary.Evo
|
||||
[InitializeOnLoad]
|
||||
public class LoginAssetWindow : OdinEditorWindow
|
||||
{
|
||||
[MenuItem("Evo/登录", false, 3)]
|
||||
[MenuItem("Evo/登录", false, 0)]
|
||||
static void Init()
|
||||
{
|
||||
var window = (LoginAssetWindow)EditorWindow.GetWindow(typeof(LoginAssetWindow));
|
||||
|
||||
@@ -148,25 +148,6 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddArtMark(Action complete)
|
||||
{
|
||||
_packageName = BuildArtAssetWindow.GetBuildPackageName();
|
||||
AssetBundleCollectorPackage assetBundleCollectorPackage = null;
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
if (package.PackageName ==_packageName)
|
||||
{
|
||||
assetBundleCollectorPackage = package;
|
||||
}
|
||||
}
|
||||
if (assetBundleCollectorPackage != null)
|
||||
{
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
|
||||
}
|
||||
MarkArt();
|
||||
CollectSVC(ArtRoot, _packageName,complete);
|
||||
}
|
||||
|
||||
public static void AddDomainMark()
|
||||
{
|
||||
// //清空主包旧数据
|
||||
|
||||
@@ -5,4 +5,24 @@ namespace Stary.Evo
|
||||
Login,
|
||||
Build,
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建管线类型
|
||||
/// </summary>
|
||||
public enum BuildPipelineType
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器下的模拟构建管线(ESBP)
|
||||
/// </summary>
|
||||
EditorSimulateBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 可编程构建管线 (SBP)
|
||||
/// </summary>
|
||||
ScriptableBuildPipeline,
|
||||
|
||||
// /// <summary>
|
||||
// /// 原生文件构建管线 (RFBP)
|
||||
// /// </summary>
|
||||
// RawFileBuildPipeline,
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ namespace Stary.Evo
|
||||
private TransformCtor transformCtor;
|
||||
|
||||
public ProgressBarPanel ProgressBarPanel { get; set; }
|
||||
|
||||
public bool IsLogin = false;
|
||||
public void SetOpenDomainType(OpenDomainType type)
|
||||
{
|
||||
this.OpenDomainType = type;
|
||||
|
||||
@@ -23,18 +23,6 @@ namespace Stary.Evo
|
||||
Debug.Log("UnityEvo:启动开始资源初始化...");
|
||||
|
||||
|
||||
//初始化读取资源配置表
|
||||
HotfixMainResDomain hotfixMainResDomain = Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
|
||||
if (hotfixMainResDomain != null)
|
||||
{
|
||||
AppConfig.IpConfig = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
|
||||
AppConfig.UserName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
|
||||
AppConfig.PassWord = hotfixMainResDomain.hotfixMainResDomainEntity.password;
|
||||
AppConfig.ProductName =Application.identifier;
|
||||
AppConfig.MainDomainVersion = hotfixMainResDomain.hotfixMainResDomainEntity.mainDomainVersion;
|
||||
}
|
||||
|
||||
Debug.Log($"UnityEvo:读取资源配置表成功...{AppConfig.IpConfig}{AppConfig.UserName}{AppConfig.PassWord}");
|
||||
// 初始化资源系统
|
||||
YooAssets.Initialize();
|
||||
//初始化资源加载模块
|
||||
@@ -56,14 +44,14 @@ namespace Stary.Evo
|
||||
await OFFLINE_PLAYMODE(package);
|
||||
await FsmSystem.SetCurState(nameof(ResUpdateLocalState));
|
||||
#elif HOST_PLAYMODE
|
||||
|
||||
//登录
|
||||
string url = AppConfig.IpConfig + "/Authentication/login";
|
||||
bool isLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
|
||||
if (isLogin)
|
||||
if (((FsmLoadSystem)FsmSystem).IsLogin)
|
||||
await HOST_PLAYMODE(package);
|
||||
else
|
||||
{
|
||||
await OFFLINE_PLAYMODE(package);
|
||||
await ChChe_PLAYMODE(package);
|
||||
}
|
||||
|
||||
|
||||
await FsmSystem.SetCurState(nameof(ResUpdateLocalState));
|
||||
@@ -113,7 +101,6 @@ namespace Stary.Evo
|
||||
|
||||
private async UniTask EDITOR_SIMULATEMODE(ResourcePackage package)
|
||||
{
|
||||
|
||||
var initParams = YooAssetFileSystem.EditorSimulateInitializeParameter(package.PackageName);
|
||||
var initialization = package.InitializeAsync(initParams);
|
||||
await initialization;
|
||||
@@ -127,12 +114,20 @@ namespace Stary.Evo
|
||||
Debug.LogError($"UnityEvo:资源包初始化失败:{initialization.Error}");
|
||||
}
|
||||
}
|
||||
|
||||
private async UniTask ChChe_PLAYMODE(ResourcePackage package)
|
||||
{
|
||||
Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
|
||||
//Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
|
||||
var initParams = YooAssetFileSystem.HostInitializeParameter();
|
||||
var initOperation = package.InitializeAsync(initParams);
|
||||
await initOperation;
|
||||
if (initOperation.Status == EOperationStatus.Succeed)
|
||||
Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
|
||||
}
|
||||
|
||||
|
||||
var operation = package.RequestPackageVersionAsync();
|
||||
await operation;
|
||||
@@ -140,37 +135,87 @@ namespace Stary.Evo
|
||||
{
|
||||
PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
|
||||
Debug.Log("UnityEvo:从本地缓存中加载资源包,初始化获取版本号成功!");
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:从本地缓存中加载资源包,初始化获取版本号失败!");
|
||||
}
|
||||
|
||||
if (initOperation.Status == EOperationStatus.Succeed)
|
||||
Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
|
||||
else
|
||||
Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
|
||||
}
|
||||
|
||||
private async UniTask OFFLINE_PLAYMODE(ResourcePackage package)
|
||||
{
|
||||
var initParams=YooAssetFileSystem.OfflineInitializeParameter();
|
||||
var initOperation = package.InitializeAsync(initParams);
|
||||
await initOperation;
|
||||
|
||||
var operation = package.RequestPackageVersionAsync();
|
||||
await operation;
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
|
||||
Debug.Log("UnityEvo:从本地加载资源包,初始化获取版本号成功!");
|
||||
}else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:从本地加载资源包,初始化获取版本号失败!");
|
||||
Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
|
||||
CopyLocalFile();
|
||||
// var initParams = YooAssetFileSystem.OfflineInitializeParameter();
|
||||
// var initOperation = package.InitializeAsync(initParams);
|
||||
// await initOperation;
|
||||
//
|
||||
// var operation = package.RequestPackageVersionAsync();
|
||||
// await operation;
|
||||
// if (operation.Status == EOperationStatus.Succeed)
|
||||
// {
|
||||
// PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
|
||||
// Debug.Log("UnityEvo:从本地StreamingAssets加载资源包,初始化获取版本号成功!");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError($"UnityEvo:从本地StreamingAssets加载资源包,初始化获取版本号失败!");
|
||||
// }
|
||||
//
|
||||
// if (initOperation.Status == EOperationStatus.Succeed)
|
||||
// Debug.Log("UnityEvo:从本地StreamingAssets加载资源包,初始化成功!");
|
||||
// else
|
||||
// Debug.LogError($"UnityEvo:从本地StreamingAssets加载资源包,初始化失败:{initOperation.Error}");
|
||||
}
|
||||
|
||||
if (initOperation.Status == EOperationStatus.Succeed)
|
||||
Debug.Log("UnityEvo:从本地加载资源包,初始化成功!");
|
||||
private void CopyLocalFile()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
// 将StreamingAssets下指定的package拷贝到目标路径
|
||||
string sourcePath = Path.Combine(Application.streamingAssetsPath,
|
||||
YooAssetSettingsData.GetDefaultYooFolderName(), AppConfig.PackageDomainName);
|
||||
string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent",
|
||||
AppConfig.PackageDomainName);
|
||||
|
||||
// 创建目标目录(如果不存在)
|
||||
if (!Directory.Exists(loadPath))
|
||||
{
|
||||
Directory.CreateDirectory(loadPath);
|
||||
}
|
||||
else
|
||||
Debug.LogError($"UnityEvo:从本地加载资源包,初始化失败:{initOperation.Error}");
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查源路径是否存在
|
||||
if (Directory.Exists(sourcePath))
|
||||
{
|
||||
// 拷贝所有文件
|
||||
string[] files = Directory.GetFiles(sourcePath, "*", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
// 计算目标文件路径
|
||||
string relativePath = Path.GetRelativePath(sourcePath, file);
|
||||
string destFile = Path.Combine(loadPath, relativePath);
|
||||
|
||||
// 创建目标子目录(如果不存在)
|
||||
string destDir = Path.GetDirectoryName(destFile);
|
||||
if (!Directory.Exists(destDir))
|
||||
{
|
||||
Directory.CreateDirectory(destDir);
|
||||
}
|
||||
|
||||
// 拷贝文件
|
||||
File.Copy(file, destFile, true);
|
||||
}
|
||||
|
||||
Debug.Log($"UnityEvo:成功将StreamingAssets下的{AppConfig.PackageDomainName}包拷贝到{loadPath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:StreamingAssets下的{AppConfig.PackageDomainName}包不存在");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public async UniTask HOST_PLAYMODE(ResourcePackage package)
|
||||
@@ -242,12 +287,14 @@ namespace Stary.Evo
|
||||
// 等一帧,让系统真正释放句柄
|
||||
await UniTask.DelayFrame(1);
|
||||
}
|
||||
|
||||
FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
|
||||
if (loadSystem.ProgressBarPanel == null)
|
||||
{
|
||||
loadSystem.ProgressBarPanel = Object.Instantiate(Resources.Load<GameObject>("ProgressBarPanel"),
|
||||
Camera.main.transform).GetOrAddComponent<ProgressBarPanel>();
|
||||
}
|
||||
|
||||
await ZipTool.DownloadAndUnzipAsync(fileId, loadPath, DownLoadProgress, UnzipProgress);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,38 +20,17 @@ namespace Stary.Evo
|
||||
|
||||
//更新失败
|
||||
|
||||
Debug.Log($"UnityEvo:切换为加载本地缓存资源...");
|
||||
string packageVersion = "";
|
||||
// if (package.PackageName.Equals("Main"))
|
||||
// {
|
||||
// var operation = package.RequestPackageVersionAsync();
|
||||
// await operation;
|
||||
// if (operation.Status == EOperationStatus.Succeed)
|
||||
// {
|
||||
// //更新成功
|
||||
// packageVersion = operation.PackageVersion;
|
||||
// Debug.Log($"Unity:【Main】Request package Version : {packageVersion}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //更新失败
|
||||
// Debug.LogError("Unity:【Main】" + operation.Error);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
{
|
||||
Debug.Log($"UnityEvo:开始加载本地缓存资源...");
|
||||
|
||||
// 获取上次成功记录的版本
|
||||
packageVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION", string.Empty);
|
||||
string packageVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION", string.Empty);
|
||||
if (string.IsNullOrEmpty(packageVersion))
|
||||
{
|
||||
Debug.Log($"UnityEvo:没有找到本地版本记录,需要更新资源!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
|
||||
Debug.Log($"UnityEvo:开始加载本地资源...");
|
||||
// Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
||||
|
||||
|
||||
@@ -74,7 +53,7 @@ namespace Stary.Evo
|
||||
|
||||
|
||||
//4.下载补丁包
|
||||
await Download();
|
||||
//await Download();
|
||||
|
||||
|
||||
//加载热更配置文件
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Stary.Evo
|
||||
/// </summary>
|
||||
public string loadDomain;
|
||||
|
||||
private void Awake()
|
||||
private async void Awake()
|
||||
{
|
||||
if (Global == null)
|
||||
{
|
||||
@@ -39,6 +39,22 @@ namespace Stary.Evo
|
||||
_devLoadSystem.AddState(new HotFixState(_devLoadSystem));
|
||||
_devLoadSystem.AddState(new LoadResState(_devLoadSystem));
|
||||
//_fsmSystem.AddState(new LoadResMainState(_fsmSystem));
|
||||
|
||||
//初始化读取资源配置表
|
||||
HotfixMainResDomain hotfixMainResDomain = Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
|
||||
if (hotfixMainResDomain != null)
|
||||
{
|
||||
AppConfig.IpConfig = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
|
||||
AppConfig.UserName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
|
||||
AppConfig.PassWord = hotfixMainResDomain.hotfixMainResDomainEntity.password;
|
||||
AppConfig.ProductName = Application.identifier;
|
||||
AppConfig.MainDomainVersion = hotfixMainResDomain.hotfixMainResDomainEntity.mainDomainVersion;
|
||||
}
|
||||
|
||||
Debug.Log($"UnityEvo:读取资源配置表成功...{AppConfig.IpConfig}{AppConfig.UserName}{AppConfig.PassWord}");
|
||||
//登录
|
||||
string url = AppConfig.IpConfig + "/Authentication/login";
|
||||
_devLoadSystem.IsLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
namespace Stary.Evo
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using YooAsset;
|
||||
|
||||
public class CopyLocalFileServices : ICopyLocalFileServices
|
||||
{
|
||||
private class AndroidWrapper
|
||||
{
|
||||
public static void CopyAssetFile(string assetPath, string destPath)
|
||||
{
|
||||
// 注意:请实现安卓平台拷贝内置文件的原生接口
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyFile(LocalFileInfo sourceFileInfo, string destFilePath)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
// 安卓平台包体内文件的拷贝走安卓原生方法
|
||||
if (IsBuildinSourceFile(sourceFileInfo.SourceFileURL))
|
||||
{
|
||||
// SourceFileURL示例 jar:file:///apk_path!/assets/yoo/DefaultPackage/xxxxxx.bundle
|
||||
AndroidWrapper.CopyAssetFile(sourceFileInfo.SourceFileURL, destFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
string sourceFilePath = ConvertFileUriToPath(sourceFileInfo.SourceFileURL);
|
||||
File.Copy(sourceFilePath, destFilePath);
|
||||
}
|
||||
#elif UNITY_OPENHARMONY
|
||||
// 鸿蒙平台处理方式
|
||||
......
|
||||
#else
|
||||
// 其它平台本地文件拷贝走正常方法
|
||||
string sourceFilePath = ConvertFileUriToPath(sourceFileInfo.SourceFileURL);
|
||||
File.Copy(sourceFilePath, destFilePath);
|
||||
#endif
|
||||
}
|
||||
|
||||
// 检测本地文件URL地址是否为安卓内包体文件
|
||||
private bool IsBuildinSourceFile(string fileURL)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileURL))
|
||||
return false;
|
||||
|
||||
// 判断是否包含APK路径特征
|
||||
return fileURL.StartsWith("jar:file://", StringComparison.OrdinalIgnoreCase) &&
|
||||
fileURL.Contains("!/assets/");
|
||||
}
|
||||
|
||||
// 本地文件URL地址转换为标准文件路径
|
||||
public static string ConvertFileUriToPath(string uri)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uri))
|
||||
return uri;
|
||||
|
||||
// 处理标准 file:// URL
|
||||
if (uri.StartsWith("file://", StringComparison.Ordinal))
|
||||
{
|
||||
// 去除 file:// 前缀
|
||||
string path = uri.Substring(7);
|
||||
|
||||
// 处理 Android 特殊格式 (file:/// 后跟绝对路径)
|
||||
if (path.StartsWith("//"))
|
||||
return path.Substring(1);
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03c2e33161bb453aa60dcb3de5868c77
|
||||
timeCreated: 1767602860
|
||||
@@ -8,15 +8,19 @@ namespace Stary.Evo
|
||||
public static InitializeParameters OfflineInitializeParameter()
|
||||
{
|
||||
var buildinFileSystemParams = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
||||
// ICopyLocalFileServices copyLocalFileServices = new CopyLocalFileServices();
|
||||
// buildinFileSystemParams.AddParameter(FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES, copyLocalFileServices);
|
||||
var initParameters = new OfflinePlayModeParameters();
|
||||
initParameters.BuildinFileSystemParameters = buildinFileSystemParams;
|
||||
return initParameters;
|
||||
|
||||
}
|
||||
public static InitializeParameters HostInitializeParameter()
|
||||
{
|
||||
var initParameters = new OfflinePlayModeParameters();
|
||||
var buildinFileSystemParams = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(null,
|
||||
$"{Application.temporaryCachePath}/DownloadedContent/{AppConfig.PackageDomainName}");
|
||||
Debug.Log($"UnityEvo:Host InitializeParameterPath: 【{Application.temporaryCachePath}/DownloadedContent/{AppConfig.PackageDomainName}】");
|
||||
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, true);
|
||||
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST, true);
|
||||
initParameters.BuildinFileSystemParameters = buildinFileSystemParams;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.tools",
|
||||
"version": "1.2.17",
|
||||
"version": "1.3.0",
|
||||
"displayName": "00.StaryEvo.Tools",
|
||||
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
||||
"unity": "2021.3",
|
||||
|
||||
Reference in New Issue
Block a user