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

246
Visualizações
Loading a dictionary of lists of lists in Unity with Firebase

So im saving my Dictionary like this:

public void saveData()
{
    database.Child("Users").Child("User").SetValueAsync(shoppingList);    
}

But if I want to load my dictionary it always returns null when I want to access anything. I load it like this:

    public void loadData()
    {

    FirebaseDatabase.DefaultInstance.GetReference("Users").GetValueAsync().ContinueWith(task => {
        if (task.IsFaulted)
        {
            // Handle the error...
        }
        else if (task.IsCompleted)
        {
            var result = task.Result;

            var loadedDict = result.Value as Dictionary<string, List<List<string>>>;

            Debug.Log(loadedDict);       

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

0

I think what might be happening is that the var loadedDict = result.Value as Dictionary<string, List<List<string>>>; is not making the conversion rightaway.

I would check the following.

1.- That the data is being properly saved in the save stage, and stored in the database and confirm that in the question.

2.- Even the dictionary is null, check if the data returned from the task is null. Because the data might be being retrieved in the var result = task.Result;, but the conversion to the dictionary not working. I would also confirm that in the question if that is the case.

3.- If the data is actually being retrieved in stage 2, and what is not working is the conversion. As far as the documentation says, the values returned native types are:

bool, string, long, double, IDictionary{string, object} and List{object}

If you are receiving the data but the loadedDict is null, you will need to code the method that converts the IDictionary{string, object} to your Dictionary<string, List<List<string>>> with your info filled in.

I did not use firebase with unity, only in web projects, so I am not sure if this might by your problem, is just my guess. I'll be glad to check what you find out

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