Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

303
Visualizações
Unable to configure saving and loading with firebase

I followed all steps such as adding the database SDK to Unity etc., but when I try to connect Unity to Firebase, I'm getting an error.

Assets\Script\RealTimeLoading.cs(14,21): error CS0029: Cannot implicitly convert type 'Firebase.Database.DatabaseReference' to 'DatabaseReference'

I followed a lot of tutorials, they are never getting errors, just me. Here is my code

 using Firebase;
 using Firebase.Database;
 using Firebase.Unity.Editor;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class RealTimeLoading : MonoBehaviour
 {
     DatabaseReference reference;
     // Start is called before the first frame update
     void Start()
     {
         reference = FirebaseDatabase.DefaultInstance.RootReference;
        
 
 
     }
     // Update is called once per frame
     void Update()
     {
         
     }
 }

The error is on this line:

 FirebaseDatabase.DefaultInstance.RootReference;

What did I do wrong?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

After briefly going through your using statements, I don't believe that there should be a DatabaseReference other than the one in Firebase.Database. That makes me think that you have another class in your project's root namespace with the same name.

First, I'd recommend removing Firebase.Unity.Editor and definitely let me know if there's still some documentation recommending it.

Then you should be able to simply write:

using DatabaseReference = Firebase.Database.DatabaseReference;

with your other using directives. So the top of your file may look like:

using Firebase;
using Firebase.Database;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using DatabaseReference = Firebase.Database.DatabaseReference;

Be careful with this because if there is another class named DatabaseReference in your code base, you may run into this naming conflict more often. It could be beneficial to either move it to its own namespace or to rename it if possible. But this should get you unstuck immediately.

Alternatively: instead of adding the using alias, you may instead fully qualify the name in your class. For example:

using Firebase;
using Firebase.Database;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class RealTimeLoading : MonoBehaviour
{
    Firebase.Database.DatabaseReference reference;
    // Start is called before the first frame update
    void Start()
    {
        reference = FirebaseDatabase.DefaultInstance.RootReference;
    }
}

I would recommend against doing both of these in one file, but you may have to use each under different circumstances.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda