This commit is contained in:
FloatGaming
2026-07-26 03:44:27 +08:00
parent 86351dbd2a
commit add675e45d
223 changed files with 1960 additions and 10735 deletions
+22 -6
View File
@@ -53,6 +53,8 @@ public class ScoreManager : MonoBehaviour
private readonly TextMeshProUGUI[] slotTmpFallback = new TextMeshProUGUI[5];
private readonly Text[] slotLegacyFallback = new Text[5];
private readonly bool[] slotFallbackResolved = new bool[5];
private float nextIdolscoreKeyLookupTime = 0f;
private const float IdolscoreKeyLookupInterval = 0.5f;
// 性能:缓存 currentTotalScore 的 TMP/Text 组件,避免每次判定 GetComponent。
private TextMeshProUGUI _cachedTotalTmp;
@@ -324,12 +326,26 @@ public class ScoreManager : MonoBehaviour
private void EnsureIdolscoreKeys()
{
// Try to resolve missing refs (GameObject.Find doesn't return inactive objects).
if (_idolscoreKeys[0] == null) _idolscoreKeys[0] = SceneObjectLookupCache.Find("idolscoreKey_red")?.transform;
if (_idolscoreKeys[1] == null) _idolscoreKeys[1] = SceneObjectLookupCache.Find("idolscoreKey_green")?.transform;
if (_idolscoreKeys[2] == null) _idolscoreKeys[2] = SceneObjectLookupCache.Find("idolscoreKey_yellow")?.transform;
if (_idolscoreKeys[3] == null) _idolscoreKeys[3] = SceneObjectLookupCache.Find("idolscoreKey_purple")?.transform;
if (_idolscoreKeys[4] == null) _idolscoreKeys[4] = SceneObjectLookupCache.Find("idolscoreKey_blue")?.transform;
bool hasMissingKey = false;
for (int i = 0; i < _idolscoreKeys.Length; i++)
{
if (_idolscoreKeys[i] == null)
{
hasMissingKey = true;
break;
}
}
// Avoid scene lookup every frame when one of these optional key objects is absent.
if (hasMissingKey && Time.unscaledTime >= nextIdolscoreKeyLookupTime)
{
nextIdolscoreKeyLookupTime = Time.unscaledTime + IdolscoreKeyLookupInterval;
if (_idolscoreKeys[0] == null) _idolscoreKeys[0] = SceneObjectLookupCache.Find("idolscoreKey_red")?.transform;
if (_idolscoreKeys[1] == null) _idolscoreKeys[1] = SceneObjectLookupCache.Find("idolscoreKey_green")?.transform;
if (_idolscoreKeys[2] == null) _idolscoreKeys[2] = SceneObjectLookupCache.Find("idolscoreKey_yellow")?.transform;
if (_idolscoreKeys[3] == null) _idolscoreKeys[3] = SceneObjectLookupCache.Find("idolscoreKey_purple")?.transform;
if (_idolscoreKeys[4] == null) _idolscoreKeys[4] = SceneObjectLookupCache.Find("idolscoreKey_blue")?.transform;
}
for (int i = 0; i < 5; i++)
{