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.

Build a reference router

Build a reference router

From the course: Unity: Working with Google Firebase

Start my 1-month free trial

Build a reference router

- [Instructor] Accessing the real time database from our project relies on constructing Firebase references in code, and then either pulling or pushing data to them. These references are essentially paths we can specify in order to get to the right place in our json tree. These can get really long and error-prone, especially when we look at adding queries and filters later on. So it's nice to have a separate class to handle this. Our router class is going to be pretty simple and expandable. So go into your scripts folder, right-click create, C# script. We're going to name this Router. Go ahead and double-click and open it up in MonoDevelop. At the top of this script, we need our Firebase using directives. So, under Unity engine, let's add using Firebase, using Firebase.Database, and using Firebase.Unity.Editor. This last using statement is going to let us interact with our database without having to run the game in Xcode, which, honestly, makes our lives much easier going forward…

Contents