【m】临时加回local模式

This commit is contained in:
zhangzheng
2026-03-18 10:29:55 +08:00
parent 4d8a107012
commit c07f1f0be8
4 changed files with 43 additions and 25 deletions

View File

@@ -17,13 +17,15 @@ namespace Stary.Evo.Editor
private const string EditorSimulateMode = "Evo/Schema/ChangePlayer/EditorSimulateMode(编辑器调试模式)";
private const string HostPlayMode = "Evo/Schema/ChangePlayer/HostPlayMode(联机运行模式)";
private const string LocalPlayMode = "Evo/Schema/ChangePlayer/LocalPlayMode(本地运行模式)";
private const string WebPlayMode = "Evo/Schema/ChangePlayer/WebPlayMode(Web运行模式)";
[MenuItem(EditorSimulateMode, false,3)]
private static void SetEditorMode() => SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
[MenuItem(HostPlayMode, false,3)]
private static void SetHostMode() => SetPlayerMode(PLayerMode.HOST_PLAYMODE);
[MenuItem(LocalPlayMode, false,3)]
private static void SetLocalMode() => SetPlayerMode(PLayerMode.LOCAL_PLAYMODE);
// [MenuItem(WebPlayMode)]
// private static void SetWebMode() => SetPlayerMode(PLayerMode.WEB_PLAYMODE);
@@ -33,6 +35,7 @@ namespace Stary.Evo.Editor
string platform = CustomEditorPrefs.GetString("ChangePlayerSchema");
Menu.SetChecked(EditorSimulateMode, platform == PLayerMode.EDITOR_SIMULATEMODE.ToString());
Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString());
Menu.SetChecked(LocalPlayMode, platform == PLayerMode.LOCAL_PLAYMODE.ToString());
//Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString());
Debug.LogError($"ChangePlayerSchema:{platform}");
return true;
@@ -60,7 +63,7 @@ namespace Stary.Evo.Editor
// 添加解决方案文件重新生成逻辑
EditorApplication.delayCall += () =>
{
EditorApplication.ExecuteMenuItem("Assets/Open C# Project");
//EditorApplication.ExecuteMenuItem("Assets/Open C# Project");
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
Debug.Log("已强制重新生成解决方案文件");
};
@@ -74,7 +77,8 @@ namespace Stary.Evo.Editor
//联机运行模式
HOST_PLAYMODE,
//本地运行模式
LOCAL_PLAYMODE,
// //web运行模式
// WEB_PLAYMODE
}

View File

@@ -32,7 +32,7 @@ namespace Stary.Evo.Editor
var rawBuildResult = BuildRawFiles();
if (!rawBuildResult.Success)
{
Debug.LogError("视频文件打包失败!");
Debug.LogWarning("视频文件打包失败!");
return;
}

View File

@@ -42,29 +42,19 @@ namespace Stary.Evo
Debug.LogWarning($"UnityEvo:资源包 {AppConfig.PackageDomainName}_RawFile 不存在,正在尝试创建...");
packageRawFile = YooAssets.CreatePackage($"{AppConfig.PackageDomainName}_RawFile");
}
bool isInitSuccess = false;
// 初始化资源包
#if EDITOR_SIMULATEMODE
await EDITOR_SIMULATEMODE(package);
await FsmSystem.SetCurState(nameof(ResEditorSimulateState));
#elif HOST_PLAYMODE
bool isInitSuccess = false;
//登录
if (((FsmLoadSystem)FsmSystem).IsLogin)
{
bool isExit = await GetServerVersion();
if (isExit)
{
await HOST_PLAYMODE(package);
isInitSuccess = await HOST_PLAYMODE(packageRawFile);
}
else
{
await OFFLINE_PLAYMODE(package);
await ChChe_PLAYMODE(package);
await OFFLINE_PLAYMODE(packageRawFile);
isInitSuccess = await ChChe_PLAYMODE(packageRawFile);
}
await GetServerVersion();
await HOST_PLAYMODE(package);
isInitSuccess = await HOST_PLAYMODE(packageRawFile);
}
else
{
@@ -79,7 +69,14 @@ namespace Stary.Evo
await UpdateLocalPackage(packageRawFile);
await LoadHotfixSettings();
//await FsmSystem.SetCurState(nameof(ResUpdateLocalState));
#elif LOCAL_PLAYMODE
await OFFLINE_PLAYMODE(package);
await UpdateLocalPackage(package);
await OFFLINE_PLAYMODE(packageRawFile);
if (isInitSuccess)
await UpdateLocalPackage(packageRawFile);
await LoadHotfixSettings();
#elif WEB_PLAYMODE
// IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
// var webServerFileSystemParams = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
@@ -165,10 +162,29 @@ namespace Stary.Evo
private async UniTask OFFLINE_PLAYMODE(ResourcePackage package)
{
Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
CopyLocalFile(package.PackageName);
var initParams = YooAssetFileSystem.OfflineInitializeParameter();
var initOperation = package.InitializeAsync(initParams);
await initOperation;
var operation = package.RequestPackageVersionAsync();
await operation;
if (operation.Status == EOperationStatus.Succeed)
{
CustomPlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
Debug.Log("UnityEvo:从本地加载资源包,初始化获取版本号成功!");
}
else
{
Debug.LogError($"UnityEvo:从本地加载资源包,初始化获取版本号失败!");
}
if (initOperation.Status == EOperationStatus.Succeed)
Debug.Log("UnityEvo:从本地加载资源包,初始化成功!");
else
Debug.LogError($"UnityEvo:从本地加载资源包,初始化失败:{initOperation.Error}");
}
private async UniTask<bool> ChChe_PLAYMODE(ResourcePackage package)
{
//Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
@@ -260,7 +276,7 @@ namespace Stary.Evo
#endif
}
private async UniTask<bool> GetServerVersion()
private async UniTask GetServerVersion()
{
// 新增平台判断代码
#if UNITY_EDITOR
@@ -299,12 +315,10 @@ namespace Stary.Evo
Debug.LogWarning($"UnityEvo:当前版本{oldVersion}资源版本一致,自动跳过更新...");
}
return true;
}
else
{
Debug.LogWarning($"UnityEvo:获取资源版本失败: 【{resDmainMessageEntity.message}】");
return false;
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "com.staryevo.tools",
"version": "1.3.14",
"version": "1.3.15",
"displayName": "00.StaryEvo.Tools",
"description": "This is an Framework package(后台服务器版本端口9527)",
"unity": "2021.3",