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>
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using AOT.Boot;
|
||||
using HotUpdate.Net;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace HotUpdate
|
||||
{
|
||||
/// <summary>
|
||||
/// 热更稳定入口(壳通过反射/Assembly.Load 调用,签名勿改)。
|
||||
/// </summary>
|
||||
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<HotUpdateBootstrap>().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();
|
||||
|
||||
_net = gameObject.AddComponent<GameNet>();
|
||||
_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}";
|
||||
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<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
canvas.sortingOrder = 200;
|
||||
var scaler = canvasGo.AddComponent<CanvasScaler>();
|
||||
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
||||
scaler.referenceResolution = new Vector2(1080, 1920);
|
||||
canvasGo.AddComponent<GraphicRaycaster>();
|
||||
|
||||
var textGo = new GameObject("Status");
|
||||
textGo.transform.SetParent(canvasGo.transform, false);
|
||||
_hud = textGo.AddComponent<Text>();
|
||||
_hud.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
|
||||
_hud.fontSize = 28;
|
||||
_hud.color = Color.white;
|
||||
_hud.alignment = TextAnchor.LowerCenter;
|
||||
var rt = textGo.GetComponent<RectTransform>();
|
||||
rt.anchorMin = new Vector2(0.05f, 0.08f);
|
||||
rt.anchorMax = new Vector2(0.95f, 0.16f);
|
||||
rt.offsetMin = Vector2.zero;
|
||||
rt.offsetMax = Vector2.zero;
|
||||
_hud.text = "net…";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user