Example #1
0
    IEnumerator CheckGifts()
    {
        theLoginScript.ShowLoadingScreen("Checking for gift datas.");
        var ATask = theLoginScript.DBreference.Child("users").Child(theLoginScript.User.UserId).Child("Reward Mail").GetValueAsync();

        yield return(new WaitUntil(predicate: () => ATask.IsCompleted));

        if (ATask.Exception != null)
        {
            Debug.LogWarning(message: $"Failed to register task with {ATask.Exception}");
            theLoginScript.ShowLoadingScreen("Checking gift datas failed.");
        }
        else
        {
            //Data has been retrieved
            DataSnapshot snapshot = ATask.Result;

            //destroy any existing scoreboard elements
            foreach (Transform child in GiftListPanel.transform)
            {
                Destroy(child.gameObject);
            }

            int num = 0;
            //Loop through every users UID
            foreach (DataSnapshot childSnapshot in snapshot.Children.Reverse <DataSnapshot>())
            {
                GiftsID[num] = int.Parse(childSnapshot.Key.ToString());
                if (GiftsID[num] != 0)
                {
                    GameObject giftelement = Instantiate(giftElement, GiftListPanel);
                    giftelement.GetComponent <GiftElement>().SetupGiftButton(int.Parse(childSnapshot.Key.ToString()));
                }
                num += 1;
            }
            theLoginScript.HideLoadingScreen();
        }
    }