So I was having issues getting the ScoreDisplay in Laser Defender to bind to GameSession specifically when beginning the game in either the Start Scene or the Game Scene. It would be bound while playing the game and then would unbind when it loaded the Game Over Scene.
However, when I would begin loading from the Game Over Scene, it would bind correctly every time. I checked my Singletons to make sure everything was there properly, but I couldn’t get it to work as I intended from the Start or Game Scene. If you guys had any ideas on how to fix it, I’d appreciate it, but I have this code below in my ScoreDisplay.cs as a bandaid solution until I figure out how to fix it.
Also, are there any performance downsides to calling an if like this every frame, or does it only call this statement when it needs to?
void Update()
{
if (!gameSession)
{
gameSession = FindObjectOfType<GameSession>();
UpdateScore();
}
}