Display points

Hello I’m new using unity and working on my 2D project, I have one issue and it’s displaying the score in my gameover scene. Can someone help me on this thanks! Btw I have 3 scenes: main. Level1 and gameover so I want to display your score on the gameover from Level1.

Generally one uses a GameManager to keep the score alive from scene to scene, then you just have UI components and scripts to retrieve and display the score in any scene that needs it, such as Level1 or Gameover or wherever.

Google on Youtube for GameManagers and generally how they work. Here are two simple approaches:

ULTRA-simple static solution to a GameManager:

OR for a more-complex “lives as a MonoBehaviour” solution…

Simple Singleton (UnitySingleton):

Some super-simple Singleton examples to take and modify:

Simple Unity3D Singleton (no predefined data):

Unity3D Singleton with a Prefab (or a ScriptableObject) used for predefined data:

These are pure-code solutions, do not put anything into any scene, just access it via .Instance!

If it is a GameManager, when the game is over, make a function in that singleton that Destroys itself so the next time you access it you get a fresh one, something like:

public void DestroyThyself()
{
   Destroy(gameObject);
   Instance = null;    // because destroy doesn't happen until end of frame
}