Files
AIGame/AIClient/Assets/Editor/YooAsset/ConfigureBootPlayMode.cs
T
udxandCursor b7a0bbcb89 Add hot-update boot pipeline, UI bundles/atlas assets, and design docs.
Ignore AIClient/Library and AIClient/HybridCLRData permanently; include HybridCLR/YooAsset project setup and UI tooling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-21 16:02:58 +08:00

57 lines
2.4 KiB
C#

#if UNITY_EDITOR
using AOT.Boot;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using YooAsset;
namespace AOT.Editor.YooAssetTools
{
/// <summary>
/// 切换 BootDriver 的 M1 验证模式(Offline / Host / Direct)。
/// </summary>
public static class ConfigureBootPlayMode
{
const string BootScene = "Assets/Scenes/Boot.unity";
[MenuItem("AIGame/Boot/Mode/Editor Direct (M0)")]
public static string SetDirect() => Apply(
EPlayMode.EditorSimulateMode,
editorDirect: true,
versionUrl: "https://www.xworld.ren/wechat/version.json",
defaultCdn: "https://www.xworld.ren/wechat/1.0.0/DefaultPackage");
[MenuItem("AIGame/Boot/Mode/Offline Smoke (M1)")]
public static string SetOffline() => Apply(EPlayMode.OfflinePlayMode, editorDirect: false);
[MenuItem("AIGame/Boot/Mode/Host Local CDN (M1)")]
public static string SetHostLocal() => Apply(EPlayMode.HostPlayMode, editorDirect: false,
versionUrl: "http://127.0.0.1:8787/wechat/version.json",
defaultCdn: "http://127.0.0.1:8787/wechat/1.0.0/DefaultPackage");
static string Apply(EPlayMode playMode, bool editorDirect, string versionUrl = null, string defaultCdn = null)
{
var scene = EditorSceneManager.OpenScene(BootScene, OpenSceneMode.Single);
var boot = Object.FindObjectOfType<BootDriver>();
if (boot == null)
return "fail: BootDriver not found in Boot scene";
var so = new SerializedObject(boot);
var settings = so.FindProperty("settings");
settings.FindPropertyRelative("PlayMode").enumValueIndex = (int)playMode;
settings.FindPropertyRelative("EditorDirectHotUpdate").boolValue = editorDirect;
if (!string.IsNullOrEmpty(versionUrl))
settings.FindPropertyRelative("VersionUrl").stringValue = versionUrl;
if (!string.IsNullOrEmpty(defaultCdn))
settings.FindPropertyRelative("DefaultCdnRoot").stringValue = defaultCdn;
so.ApplyModifiedPropertiesWithoutUndo();
EditorSceneManager.MarkSceneDirty(scene);
EditorSceneManager.SaveScene(scene);
return $"ok playMode={playMode} editorDirect={editorDirect} versionUrl={settings.FindPropertyRelative("VersionUrl").stringValue}";
}
}
}
#endif