FirebaseDatabase.DefaultInstance.RootReference == null

Hello everyone,

I am actually trying to get my application working together with a Firebase Realtime Database.
For some time getting the reference to the database worked fine. It is actually a quite simple line:

FirebaseDatabase.DefaultInstance.RootReference

But now it returns null and I do not have an idea why?!

private void InitializeFirebase()
    {
        Debug.Log("Initializing FirebaseManagerGame + DB");
        try
        {
            DBreference = FirebaseDatabase.DefaultInstance.RootReference;
        }
        catch (Exception e)
        {
            Debug.Log("Gotacha! " + e.Message);
            if (DBreference == null)
                Debug.Log("DBreference is null");
            throw e;
        }

Output:

Gotacha! Object reference not set to an instance of an object
UnityEngine.Debug:Log (object)
FirebaseManagerGame:InitializeFirebase () (at Assets/Scripts/FirebaseManagerGame.cs:72)
FirebaseManagerGame:<Awake>b__4_0 (System.Threading.Tasks.Task`1<Firebase.DependencyStatus>) (at Assets/Scripts/FirebaseManagerGame.cs:44)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()

DBreference is null

Do you have any idea why?

By the way: WIthout the try catch block I do not see any exception. It simply does not work and the exception is hidden, which does not really make it easy to find the problem…

I just solved the problem, but I do not understand why… Hopefully anyone can explain it to me so that I can avoid similar problems in the future.

I used an empty game object and attached my 2 FirebaseManager scripts. The …Auth script is only needed at my GameMenu scene, so I divided them.

It turned out that attaching both scripts to one game object causes the curious problem mentioned above.

I solved it by creating another game object and attaching one of the 2 scripts to the new object so that at the end I have 2 game objects with each 1 script attached.

Are there maybe any competing actions taking place if both scripts belong to one game object?