优化一大波
This commit is contained in:
@@ -41,6 +41,8 @@ namespace GameFramework
|
||||
private EchoSystem _echoSystem;
|
||||
private PlayerController _playerController;
|
||||
private int _maxHealth = 5;
|
||||
private bool _subscribedScoreEvent = false;
|
||||
private int _lastSoulCount = -1;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -64,6 +66,7 @@ namespace GameFramework
|
||||
if (ScoreManager.Instance != null)
|
||||
{
|
||||
ScoreManager.onScoreChanged += UpdateSoulCount;
|
||||
_subscribedScoreEvent = true;
|
||||
UpdateSoulCount(ScoreManager.Instance.CurrentScore);
|
||||
}
|
||||
|
||||
@@ -79,7 +82,11 @@ namespace GameFramework
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
ScoreManager.onScoreChanged -= UpdateSoulCount;
|
||||
if (_subscribedScoreEvent)
|
||||
{
|
||||
ScoreManager.onScoreChanged -= UpdateSoulCount;
|
||||
_subscribedScoreEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -96,7 +103,11 @@ namespace GameFramework
|
||||
if (soulCountText != null)
|
||||
{
|
||||
soulCountText.text = count.ToString();
|
||||
Debug.Log($"[GameHUD] UpdateSoulCount: {count}");
|
||||
if (count != _lastSoulCount)
|
||||
{
|
||||
Debug.Log($"[GameHUD] UpdateSoulCount: {count}");
|
||||
_lastSoulCount = count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user