using AOT.Boot;
using HotUpdate.Net;
using UnityEngine;
using UnityEngine.UI;
namespace HotUpdate
{
///
/// 热更稳定入口(壳通过反射/Assembly.Load 调用,签名勿改)。
///
public static class Entry
{
public static void Start(BootContext ctx)
{
Debug.Log($"[HotUpdate.Entry] Start app={ctx?.AppVersion} res={ctx?.ResVersion}");
var root = new GameObject("HotUpdateRoot");
Object.DontDestroyOnLoad(root);
root.AddComponent().Bind(ctx);
}
}
public sealed class HotUpdateBootstrap : MonoBehaviour
{
BootContext _ctx;
GameNet _net;
Text _hud;
public void Bind(BootContext ctx)
{
_ctx = ctx;
}
void Start()
{
Debug.Log($"[HotUpdate] Bootstrap ready. CDN={_ctx?.CdnRoot}");
EnsureHud();
// M3:示例角色(与网络并行,不依赖 WS)
var spawner = gameObject.AddComponent();
spawner.Bind(_ctx);
spawner.Spawn();
_net = gameObject.AddComponent();
_net.Bind(_ctx);
_net.OnStatus += s =>
{
if (_hud != null) _hud.text = s;
};
_net.OnWsReady += () =>
{
if (_hud != null)
_hud.text = $"WS OK pid={_net.Session?.Pid} | MaleExplorer";
Debug.Log($"[HotUpdate] M2 WS ready pid={_net.Session?.Pid}");
};
_net.StartGuestSession();
}
void EnsureHud()
{
var canvasGo = new GameObject("NetHud");
canvasGo.transform.SetParent(transform, false);
var canvas = canvasGo.AddComponent