改动与优化

This commit is contained in:
FloatGaming
2026-07-20 22:19:25 +08:00
parent 0a0872c4f4
commit b5d1cdcbc5
83 changed files with 2475 additions and 276 deletions
+54 -1
View File
@@ -15,6 +15,7 @@ public class itemGetPrefab : MonoBehaviour
public Button close;
private readonly List<GameObject> spawnedItems = new List<GameObject>();
private Coroutine layoutRefreshRoutine;
private void Awake()
{
@@ -52,6 +53,8 @@ public class itemGetPrefab : MonoBehaviour
Destroy(displayParent.GetChild(i).gameObject);
}
}
RequestLayoutRebuild();
}
public get_item_prefab AddItem()
@@ -63,11 +66,61 @@ public class itemGetPrefab : MonoBehaviour
GameObject instance = Instantiate(itemPrefab, displayParent);
spawnedItems.Add(instance);
UI_OrderedEntryAnimator.PlayFadeOnly(instance, spawnedItems.Count - 1, 0.2f, 0.025f, true);
RequestLayoutRebuild();
return instance.GetComponent<get_item_prefab>();
}
private void RequestLayoutRebuild()
{
if (displayParent == null)
{
return;
}
if (layoutRefreshRoutine != null)
{
StopCoroutine(layoutRefreshRoutine);
layoutRefreshRoutine = null;
}
if (isActiveAndEnabled)
{
layoutRefreshRoutine = StartCoroutine(RebuildLayoutNextFrame());
return;
}
RebuildLayoutNow();
}
private System.Collections.IEnumerator RebuildLayoutNextFrame()
{
yield return null;
RebuildLayoutNow();
layoutRefreshRoutine = null;
}
private void RebuildLayoutNow()
{
RectTransform rect = displayParent as RectTransform;
if (rect == null)
{
return;
}
Canvas.ForceUpdateCanvases();
LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
Canvas.ForceUpdateCanvases();
}
public void CloseSelf()
{
Destroy(gameObject);
UI_PanelExitUtility.PlayExitThen(gameObject, () =>
{
if (gameObject != null)
{
Destroy(gameObject);
}
});
}
}