【m】增加web第一版暂存
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 4s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 4s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 10s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 5s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 32s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 4s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 16s
Plugin Library CI / publish (07.RKTools) (push) Successful in 3s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 3s
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 4s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 4s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 10s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 5s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 32s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 4s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 16s
Plugin Library CI / publish (07.RKTools) (push) Successful in 3s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 3s
This commit is contained in:
@@ -52,7 +52,6 @@ namespace Stary.Evo
|
||||
//登录
|
||||
if ((AppConfig.IsLogin))
|
||||
{
|
||||
await GetServerVersion();
|
||||
await HOST_PLAYMODE(package);
|
||||
isInitSuccess = await HOST_PLAYMODE(packageRawFile);
|
||||
}
|
||||
@@ -78,24 +77,10 @@ namespace Stary.Evo
|
||||
await UpdateLocalPackage(packageRawFile);
|
||||
await LoadHotfixSettings();
|
||||
#elif WEB_PLAYMODE
|
||||
// IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
||||
// var webServerFileSystemParams = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
|
||||
// var webRemoteFileSystemParams =
|
||||
// FileSystemParameters.CreateDefaultWebRemoteFileSystemParameters(remoteServices); //支持跨域下载
|
||||
//
|
||||
// var initParameters = new WebPlayModeParameters();
|
||||
// initParameters.WebServerFileSystemParameters = webServerFileSystemParams;
|
||||
// initParameters.WebRemoteFileSystemParameters = webRemoteFileSystemParams;
|
||||
//
|
||||
// var initOperation = package.InitializeAsync(initParameters);
|
||||
// await initOperation;
|
||||
//
|
||||
// if (initOperation.Status == EOperationStatus.Succeed)
|
||||
// Debug.Log("UnityEvo:资源包初始化成功!");
|
||||
// else
|
||||
// Debug.LogError($"UnityEvo:资源包初始化失败:{initOperation.Error}");
|
||||
|
||||
Debug.LogError($"UnityEvo:暂不支持");
|
||||
await WEB_PLAYMODE(package);
|
||||
await UpdateLocalPackage(package);
|
||||
await LoadHotfixSettings();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -119,6 +104,19 @@ namespace Stary.Evo
|
||||
|
||||
private async UniTask<bool> HOST_PLAYMODE(ResourcePackage package)
|
||||
{
|
||||
var resDmainResponse = await GetServerDomainVersion();
|
||||
//获取当前版本
|
||||
var oldVersion = CustomPlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION");
|
||||
//版本不一致,开始下载
|
||||
if (resDmainResponse.PackageVersion != oldVersion)
|
||||
{
|
||||
await Download(resDmainResponse.DocumentFileId);
|
||||
CustomPlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION",resDmainResponse.PackageVersion);
|
||||
}
|
||||
else //版本一致,加载缓存资源
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:当前版本{oldVersion}资源版本一致,自动跳过更新...");
|
||||
}
|
||||
var initParams = YooAssetFileSystem.HostInitializeParameter(package.PackageName);
|
||||
// initParameters.CacheFileSystemParameters = cacheFileSystemParams;
|
||||
try
|
||||
@@ -145,6 +143,36 @@ namespace Stary.Evo
|
||||
return false;
|
||||
}
|
||||
|
||||
private async UniTask<bool> WEB_PLAYMODE(ResourcePackage package)
|
||||
{
|
||||
var path = await GetServerVersionPath();
|
||||
string defaultHostServer = $"{AppConfig.IpConfig}/StaticFiles{path}";
|
||||
var initParams = YooAssetFileSystem.WebInitializeParameter(package.PackageName, defaultHostServer,"");
|
||||
// initParameters.CacheFileSystemParameters = cacheFileSystemParams;
|
||||
try
|
||||
{
|
||||
var initOperation = package.InitializeAsync(initParams);
|
||||
|
||||
await initOperation;
|
||||
|
||||
if (initOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
Debug.Log("UnityEvo:从Web加载资源包,初始化成功!");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:从Web加载资源包,初始化失败:{initOperation.Error}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:从Web加载资源包,初始化失败:{e}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async UniTask<bool> OFFLINE_PLAYMODE(ResourcePackage package)
|
||||
{
|
||||
var initParams = YooAssetFileSystem.OfflineInitializeParameter();
|
||||
@@ -265,7 +293,7 @@ namespace Stary.Evo
|
||||
#endif
|
||||
}
|
||||
|
||||
private async UniTask GetServerVersion()
|
||||
private async UniTask<ResDmainResponse> GetServerDomainVersion()
|
||||
{
|
||||
// 新增平台判断代码
|
||||
#if UNITY_EDITOR
|
||||
@@ -290,31 +318,53 @@ namespace Stary.Evo
|
||||
{
|
||||
ResDmainResponse resDmainResponse =
|
||||
JsonConvert.DeserializeObject<ResDmainResponse>(resDmainMessageEntity.data.ToString());
|
||||
//获取当前版本
|
||||
var oldVersion = CustomPlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION");
|
||||
//版本不一致,开始下载
|
||||
if (resDmainResponse.PackageVersion != oldVersion)
|
||||
{
|
||||
await Download(resDmainResponse.DocumentFileId);
|
||||
CustomPlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION",
|
||||
resDmainResponse.PackageVersion);
|
||||
}
|
||||
else //版本一致,加载缓存资源
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:当前版本{oldVersion}资源版本一致,自动跳过更新...");
|
||||
}
|
||||
|
||||
return resDmainResponse;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:获取资源版本失败: 【{resDmainMessageEntity.message}】");
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
private async UniTask<string> GetServerVersionPath()
|
||||
{
|
||||
var resDmainResponse = await GetServerDomainVersion();
|
||||
if (!string.IsNullOrEmpty(resDmainResponse.DocumentFileId))
|
||||
{
|
||||
try
|
||||
{
|
||||
CustomPlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION",resDmainResponse.PackageVersion);
|
||||
string url = $"{AppConfig.IpConfig}/FileLoad/QueryFileById";
|
||||
var resDmainMessageEntity = await WebRequestSystem.Get(url, resDmainResponse.DocumentFileId);
|
||||
if (resDmainMessageEntity.code == 200)
|
||||
{
|
||||
DocumentFileResponse documentFileResponse =
|
||||
JsonConvert.DeserializeObject<DocumentFileResponse>(resDmainMessageEntity.data.ToString());
|
||||
return documentFileResponse.filePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:获取资源版本失败: 【{resDmainMessageEntity.message}】");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"UnityEvo:获取资源版本失败: 【{resDmainResponse.DocumentFileId}】: {e.Message}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:获取资源版本失败: 【{resDmainResponse.DocumentFileId}】");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private async UniTask UpdateLocalPackage(ResourcePackage package)
|
||||
{
|
||||
//更新失败
|
||||
|
||||
Debug.Log($"UnityEvo:开始加载本地缓存资源...");
|
||||
|
||||
// 获取上次成功记录的版本
|
||||
string packageVersion =
|
||||
@@ -351,7 +401,7 @@ namespace Stary.Evo
|
||||
{
|
||||
//初始化读取资源配置表
|
||||
var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
|
||||
if (AppConfig.PackageDomainName.Equals("Main") || HybridClREntrance.Global.stage == StageType.Developer)
|
||||
if (HybridClREntrance.Global.stage == StageType.Developer)
|
||||
{
|
||||
//加载热更配置文件
|
||||
var loadHotfixSettingsOp = package.LoadAssetAsync<DomainConfig>("Config_DomainConfig");
|
||||
@@ -373,8 +423,12 @@ namespace Stary.Evo
|
||||
{
|
||||
Debug.LogError($"UnityEvo:【{package.PackageName}】加载DomainConfig为空,无法继续执行后续流程,请检查!!!");
|
||||
}
|
||||
|
||||
#if UNITY_WEBGL
|
||||
await FsmSystem.SetCurState(nameof(ResStartState), domainConfig,domainConfig.className);
|
||||
#else
|
||||
FsmSystem.SetCurState(nameof(HotFixDllState), domainConfig);
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (HybridClREntrance.Global.stage == StageType.Originality)
|
||||
{
|
||||
|
||||
@@ -4,9 +4,7 @@ using System.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
#if HotUpdate
|
||||
using YooAsset;
|
||||
#endif
|
||||
|
||||
namespace Stary.Evo.UIFarme
|
||||
{
|
||||
@@ -201,7 +199,6 @@ namespace Stary.Evo.UIFarme
|
||||
{
|
||||
return activePanel.gameObject;
|
||||
}
|
||||
#if HotUpdate
|
||||
AssetHandle handle = null;
|
||||
if (packageName == null)
|
||||
{
|
||||
@@ -223,10 +220,6 @@ namespace Stary.Evo.UIFarme
|
||||
await handle.Task;
|
||||
|
||||
activePanel = GameObject.Instantiate(handle.AssetObject as GameObject, panelParent);
|
||||
#else
|
||||
GameObject handle = Resources.Load<GameObject>(panelName);
|
||||
activePanel = GameObject.Instantiate(handle, panelParent);
|
||||
#endif
|
||||
|
||||
|
||||
activePanel.name = this.GetType().Name;
|
||||
|
||||
@@ -4,9 +4,7 @@ using System.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
#if HotUpdate
|
||||
using YooAsset;
|
||||
#endif
|
||||
|
||||
namespace Stary.Evo.UIFarme
|
||||
{
|
||||
@@ -163,7 +161,6 @@ namespace Stary.Evo.UIFarme
|
||||
{
|
||||
return activePanel.gameObject;
|
||||
}
|
||||
#if HotUpdate
|
||||
AssetHandle handle = null;
|
||||
if (packageName == null)
|
||||
{
|
||||
@@ -185,10 +182,6 @@ namespace Stary.Evo.UIFarme
|
||||
await handle.Task;
|
||||
|
||||
activePanel = GameObject.Instantiate(handle.AssetObject as GameObject, panelParent);
|
||||
#else
|
||||
GameObject handle = Resources.Load<GameObject>(panelName);
|
||||
activePanel = GameObject.Instantiate(handle, panelParent);
|
||||
#endif
|
||||
|
||||
activePanel.name = panelName;
|
||||
|
||||
|
||||
36
Assets/00.StaryEvoTools/Runtime/Tools/RemoteServices.cs
Normal file
36
Assets/00.StaryEvoTools/Runtime/Tools/RemoteServices.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using YooAsset;
|
||||
namespace Stary.Evo
|
||||
{
|
||||
|
||||
|
||||
public class RemoteServices : IRemoteServices
|
||||
{
|
||||
private readonly string _mainHost;
|
||||
private readonly string _fallbackHost;
|
||||
|
||||
public RemoteServices(string mainHost, string fallbackHost = null)
|
||||
{
|
||||
_mainHost = mainHost.TrimEnd('/');
|
||||
_fallbackHost = string.IsNullOrEmpty(fallbackHost)
|
||||
? _mainHost
|
||||
: fallbackHost.TrimEnd('/');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主下载地址(YooAsset 会优先使用)
|
||||
/// fileName 示例:DefaultPackage/StaticAssets/DefaultPackage.version
|
||||
/// </summary>
|
||||
public string GetRemoteMainURL(string fileName)
|
||||
{
|
||||
return $"{_mainHost}/{fileName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 备用下载地址(主地址失败时自动重试)
|
||||
/// </summary>
|
||||
public string GetRemoteFallbackURL(string fileName)
|
||||
{
|
||||
return $"{_fallbackHost}/{fileName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bfb1ccd41e3422e9b42f65c275eb0ea
|
||||
timeCreated: 1776440659
|
||||
@@ -26,6 +26,17 @@ namespace Stary.Evo
|
||||
initParameters.BuildinFileSystemParameters = buildinFileSystemParams;
|
||||
return initParameters;
|
||||
}
|
||||
public static InitializeParameters WebInitializeParameter(string packageName, string defaultHostServer, string fallbackHostServer)
|
||||
{
|
||||
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
||||
var webServerFileSystemParams = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
|
||||
var webRemoteFileSystemParams = FileSystemParameters.CreateDefaultWebRemoteFileSystemParameters(remoteServices); //支持跨域下载
|
||||
|
||||
var initParameters = new WebPlayModeParameters();
|
||||
initParameters.WebServerFileSystemParameters = webServerFileSystemParams;
|
||||
initParameters.WebRemoteFileSystemParameters = webRemoteFileSystemParams;
|
||||
return initParameters;
|
||||
}
|
||||
public static InitializeParameters EditorSimulateInitializeParameter(string packageName)
|
||||
{
|
||||
var buildResult = EditorSimulateModeHelper.SimulateBuild(packageName);
|
||||
|
||||
Reference in New Issue
Block a user