I am unable to access/edit a list variable inside a getvalueasync task, any code that tries to modify or read the list "ShopItems" returns nothing and prevents any further code from running in the same scope, no errors are being returned in the console. There are no issues with the "ItemsLoaded" int variable.
public static void IsItemPurchased(string item)
{
Debug.Log(ShopManager.ShopItems[0]); // This works
FirebaseDatabase.DefaultInstance.GetReference("/Shop/" + item + "/").GetValueAsync().ContinueWith(task =>
{
if (task.IsFaulted || task.IsCanceled)
{
Debug.LogError("Database: Failed to check item status - " + task.Exception);
}
else if (task.IsCompleted)
{
bool isPurchased;
if (task.Result.Value == null)
isPurchased = false;
else
isPurchased = (bool)task.Result.Value;
Debug.Log(ShopManager.ShopItems[0]); // Does not work
Debug.Log(ShopManager.ItemsLoaded); // This works
ShopManager.ShopItems.Where(i => i.gameObject.name == item).FirstOrDefault().Purchased = isPurchased; // Variable does not update
ShopManager.ItemsLoaded++;
}
});
}