备份,准备做双端

This commit is contained in:
2026-07-30 23:15:58 +08:00
parent add675e45d
commit ec4ec53545
88 changed files with 4050 additions and 872 deletions
@@ -344,9 +344,13 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
if (obj == null) yield break;
if (settings == null) settings = judgePopup;
SpriteRenderer[] renderers = obj.GetComponentsInChildren<SpriteRenderer>(true);
Graphic[] graphics = obj.GetComponentsInChildren<Graphic>(true);
CanvasGroup canvasGroup = obj.GetComponent<CanvasGroup>();
// Pooled popup instances keep the same child renderer/graphic set for their lifetime,
// so cache the (otherwise-allocating) GetComponentsInChildren sweeps on the instance
// and reuse them on every replay instead of re-scanning per judgement.
PopupRenderableCache cache = GetPopupRenderableCache(obj);
SpriteRenderer[] renderers = cache.renderers;
Graphic[] graphics = cache.graphics;
CanvasGroup canvasGroup = cache.canvasGroup;
float elapsed = 0f;
float vVelocity = settings.jumpForce;
@@ -433,6 +437,28 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
}
}
// Caches the child SpriteRenderer/Graphic arrays + CanvasGroup of a pooled popup instance
// so AnimatePopup doesn't re-run allocating GetComponentsInChildren on every replay.
private sealed class PopupRenderableCache : MonoBehaviour
{
public SpriteRenderer[] renderers;
public Graphic[] graphics;
public CanvasGroup canvasGroup;
}
private static PopupRenderableCache GetPopupRenderableCache(GameObject obj)
{
var cache = obj.GetComponent<PopupRenderableCache>();
if (cache == null)
{
cache = obj.AddComponent<PopupRenderableCache>();
cache.renderers = obj.GetComponentsInChildren<SpriteRenderer>(true);
cache.graphics = obj.GetComponentsInChildren<Graphic>(true);
cache.canvasGroup = obj.GetComponent<CanvasGroup>();
}
return cache;
}
private static void SetRenderersAlpha(SpriteRenderer[] renderers, float alpha)
{
if (renderers == null)