From the course: Unity: Working with Google Firebase

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

The database manager

The database manager

From the course: Unity: Working with Google Firebase

Start my 1-month free trial

The database manager

- [Instructor] Go into the scenes folder and open up the player list scene. The UI here is also pretty simple. On the left, we have a player info panel and on the right, we have a scrolling list where all our players will show up from the database. Now let's take a look at the database manager which has the database manager script on it. All I've done in this script is set up the singleton class. This will cut out any issues with conflicting calls and updates to our firebase database. If you're not familiar with the singleton design pattern, all its doing here is creating a shared instance variable initially set to null. The first time the script initializes, it'll check if the shared instance is null. If it is, we'll assign it to the current instance. However, if the shared instance already exists, the script will self destruct, leaving us with the one instance which is exactly what we want. The last line, don't destroy on load, makes sure that once an instance is successfully…

Contents