Bring in MaleExplorer assets/shaders, model tooling and Hunyuan updates, plus boot/YooAsset Art package support. Co-authored-by: Cursor <cursoragent@cursor.com>
87 lines
2.8 KiB
C#
87 lines
2.8 KiB
C#
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();
|
|
|
|
// M3:示例角色(与网络并行,不依赖 WS)
|
|
var spawner = gameObject.AddComponent<CharacterSpawner>();
|
|
spawner.Bind(_ctx);
|
|
spawner.Spawn();
|
|
|
|
_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} | 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<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…";
|
|
}
|
|
}
|
|
}
|