feat: add world chat UI

This commit is contained in:
ud18010
2026-07-28 11:54:07 +08:00
parent 09c89aadf0
commit 48aed26725
28 changed files with 5308 additions and 99 deletions
@@ -0,0 +1,52 @@
using NUnit.Framework;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using XGame;
public sealed class UIManagerAttachTests
{
[TearDown]
public void TearDown()
{
DestroyIfExists("ZeroSizedCanvas");
DestroyIfExists("UIRoot");
EventSystem eventSystem = Object.FindObjectOfType<EventSystem>();
if (eventSystem != null)
{
Object.DestroyImmediate(eventSystem.gameObject);
}
}
[Test]
public void AttachTo_StretchesZeroSizedCanvasRootAndAppliesUiLayer()
{
GameObject ui = new GameObject("ZeroSizedCanvas", typeof(RectTransform), typeof(Canvas));
GameObject child = new GameObject("Child", typeof(RectTransform), typeof(Image));
child.transform.SetParent(ui.transform, false);
RectTransform rt = ui.GetComponent<RectTransform>();
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.zero;
rt.sizeDelta = Vector2.zero;
UIManager.AttachTo(UILayer.Normal, ui);
int uiLayer = LayerMask.NameToLayer("UI");
Assert.That(rt.anchorMin, Is.EqualTo(Vector2.zero));
Assert.That(rt.anchorMax, Is.EqualTo(Vector2.one));
Assert.That(rt.offsetMin, Is.EqualTo(Vector2.zero));
Assert.That(rt.offsetMax, Is.EqualTo(Vector2.zero));
Assert.That(ui.layer, Is.EqualTo(uiLayer));
Assert.That(child.layer, Is.EqualTo(uiLayer));
}
private static void DestroyIfExists(string name)
{
GameObject go = GameObject.Find(name);
if (go != null)
{
Object.DestroyImmediate(go);
}
}
}