Cloud Storage: Firebase (optional)

For a comprehensive guide on integrating Firebase with Unity, developers are encouraged to consult the official Firebase documentation. What follows in this tutorial is a concise overview tailored to our specific use case.

Create a Firebase Project

  1. Visit the Firebase Console.

  2. Click on "Add Project" and follow the prompts to fill in the project information.

  3. Click "Create Project".

Add an App

  1. On the project overview page, click "Add App" and select the appropriate platform (e.g., Android).

  2. Follow the prompts to enter the app's package name and other information.

  3. Download and save the configuration file (google-services.json) and place it in the Assets folder.

Install the SDK

  1. Import FirebaseStorage.unitypackage into Unity.

Add Storage

  1. Go to Build > Storage

  2. Click Get Started and set up cloud storage

  3. The highlighted part in the following image is the folder location where we will upload the anchor file.

Upload/download files

We've developed a dedicated FirebaseStorageManager class to facilitate file upload and download functionalities. For detailed implementation, you can refer to the official documentation.

It's important to note that whether you're uploading or downloading, the storagePath should include the specific filename, not just the directory. This specification is also highlighted in the documentation.

Therefore, We set the file path obtained from the previous step as storageBasePath and later concatenate it with the filename to form the complete path for upload/download.

Common Issues

  1. After installing Firebase, building software in Unity may fail. This is a known issue with Android and requires adding launcherTemplate.gradle in Unity, then adding the following content:

  1. Possible error may occur:

In this case, you need to update the Google Play Service of the mobile phone.

Was this helpful?