Files
AIGame/AIClient/Assets/Editor/YooAsset/ConfigureBootPlayMode.cs
T
udxandCursor 6550b8df4b Add AIServer, character art pipeline, and Art package boot integration.
Bring in MaleExplorer assets/shaders, model tooling and Hunyuan updates, plus boot/YooAsset Art package support.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-21 17:06:59 +08:00

83 lines
3.6 KiB
C#

#if UNITY_EDITOR
using AOT.Boot;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using YooAsset;
namespace AOT.Editor.YooAssetTools
{
/// <summary>
/// 切换 BootDriver 的运行模式 / 服务器地址。
/// </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");
[MenuItem("AIGame/Boot/Server/Production game.xworld.ren")]
public static string SetServerProd() => ApplyServer(
"https://game.xworld.ren",
"wss://game.xworld.ren/ws?pid={pid}&token={token}");
[MenuItem("AIGame/Boot/Server/Local AIServer :8080")]
public static string SetServerLocal() => ApplyServer(
"http://127.0.0.1:8080",
"ws://127.0.0.1:8080/ws?pid={pid}&token={token}");
static string ApplyServer(string httpBase, string wsTemplate)
{
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("HttpBase").stringValue = httpBase;
settings.FindPropertyRelative("WsUrlTemplate").stringValue = wsTemplate;
so.ApplyModifiedPropertiesWithoutUndo();
EditorSceneManager.MarkSceneDirty(scene);
EditorSceneManager.SaveScene(scene);
return $"ok http={httpBase} ws={wsTemplate}";
}
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