好多新内容
This commit is contained in:
@@ -148,6 +148,7 @@ namespace Bansonic
|
||||
if (currentInstance != null && currentController != null)
|
||||
{
|
||||
ReparentIfNeeded();
|
||||
EnsureTopMostSorting();
|
||||
if (!currentInstance.activeInHierarchy)
|
||||
{
|
||||
currentInstance.SetActive(true);
|
||||
@@ -171,6 +172,26 @@ namespace Bansonic
|
||||
currentInstance.name = prefab.name;
|
||||
currentController = currentInstance.GetComponent<itemGetPrefab>();
|
||||
ReparentIfNeeded();
|
||||
EnsureTopMostSorting();
|
||||
}
|
||||
|
||||
// 确保 itemGet 弹窗永远显示在所有 UI 之上(包括名为 "top" 的高层覆盖界面)。
|
||||
// itemGet.prefab 本身无 Canvas,靠父 Canvas 渲染,故会被 sortingOrder 更高的 Canvas 遮挡。
|
||||
// 方案:在实例根挂一个 override sorting 的 Canvas,设定极高 sortingOrder。
|
||||
// 仅表现层:不改 itemGet 内部结构/引用/逻辑,只保证其可见性置顶。
|
||||
private const int ItemGetSortingOrder = 32760; // 接近 short.MaxValue,高于常规 UI/top
|
||||
private static void EnsureTopMostSorting()
|
||||
{
|
||||
if (currentInstance == null) return;
|
||||
|
||||
Canvas canvas = currentInstance.GetComponent<Canvas>();
|
||||
if (canvas == null) canvas = currentInstance.AddComponent<Canvas>();
|
||||
canvas.overrideSorting = true;
|
||||
canvas.sortingOrder = ItemGetSortingOrder;
|
||||
|
||||
// override Canvas 需配 GraphicRaycaster 才能接收点击(关闭按钮等)。
|
||||
if (currentInstance.GetComponent<UnityEngine.UI.GraphicRaycaster>() == null)
|
||||
currentInstance.AddComponent<UnityEngine.UI.GraphicRaycaster>();
|
||||
}
|
||||
|
||||
private static Transform ResolveParent()
|
||||
|
||||
Reference in New Issue
Block a user