So, I understand singleton pattern as Guarantee specific object exist one and only.(Plus, it make other object easy to access.)
But Isn’t it make potential problem if we manage singleton and get reference of scorekeeper at the same time-at Awake() method-? Cause if we load another scorekeeper at new scene and get reference at awake(), there is possibility that we get wrong scorekeeper first and destroy it later.
For this case, If we load game scene after game over menu, another scorekeeper is loaded from scene file, and it needs to be destroyed before UiDisplay accidentally get reference of new one. Otherwise, after UiDisplay get reference of new one, It will be destroyed so that UiDisplay have NULL reference.
But after I play test several times, I can’t find any error. UiDisplay always display score right. Why it works without potential problem.?