Drops-Smart Aqua

Praddyum Verma
27 March 2020





Let's Setup Firebase Realtime database with Unity 2019 & 2020

These steps worked fine w.r.t firebase sdk 7.1.0.
Declare a global variable Database.

  1. Create a new project in Uniy and switch the platform to Android (File -> Build Settings -> Android).
  2. In Player Settings, provide the Company Name and Product Name.
  3. Under Player Setting> -> Publishing Setting create a Keystore.
  4. Note: Multiple games/apps under the same Keystore is differentiated by Alias so use the field to give it a unique name and different password.
  5. Now head over to Firebase Console and create a new project
  6. Give it a name and turn off analytics for now.
  7. Click on the Unity Icon to add the application.
  8. Register as Android app and in Unity Player Setting and get the package name and paste it here. For App nick name give it anything of your choice. Click on Register.
  9. Click Next.
  10. Download the SDK and press Next -> Continue to Console.
  11. Now open the terminal and type keytool -list -keystore
  12. On firebase console, Settings -> Project Settings -> Your Apps and Add fingerprint.
  13. Under Build panel, click on Realtime Database -> Create Database.
  14. Choose (us-central1) for Database Location and Start in Test Mode and the click Enable.
  15. Move to Settings -> Project Settings -> Your Apps and download the google-services.json and SDK.
  16. Open the Unity project and import packages:
  17. Make an empty game object and assign it a script (Say: realtime) with code.
  18. Open UI -> Button. Under Inspector Panel of Button OnClick press on + and then drag and drop the created empty game object above and under function select realtime -> update_value.
  19. Play the game and click on button you'll see the values changing on Realtime Database console over Firebase.
  20. Visit Docs to learn other ways to send and receive data over firebase.
  21. Incase an error occurs(Can't make Firebase App etc) try downloading the google-services.json again(Step 14) and replacing it with old file under Assets folder.


Thanks for Visiting. Have a nice day.