Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The name `Array' does not exist in the current context

Tags:

c#

unity3d

Does anyone know why I'm getting this error? This shows after upgrading my project to the new version of Unity3d.

Error CS0103: The name `Array' does not exist in the current context

#if IAP && UNITY_PURCHASING
private void OnItemPurchased(IAPItem item, int index)
{
    // A consumable product has been purchased by this user.
    if (item.productType == PType.Consumable)
    {
        CurrencyController.CreditBalance(item.value);
        Toast.instance.ShowMessage("Your purchase is successful");
        CUtils.SetBuyItem();
        if(Array.IndexOf(Purchaser.instance.iapItems, item) >= 1)
        {
            CUtils.SetRemoveAds(true);
        }
    }
    // Or ... a non-consumable product has been purchased by this user.
    else if (item.productType == PType.NonConsumable)
    {
        // TODO: The non-consumable item has been successfully purchased, grant this item to the player.
    }
    // Or ... a subscription product has been purchased by this user.
    else if (item.productType == PType.Subscription)
    {
        // TODO: The subscription item has been successfully purchased, grant this to the player.
    }
}
#endif
like image 417
mhart ian cruz Avatar asked Apr 16 '18 14:04

mhart ian cruz


1 Answers

Late to the party but I wanted to add an official Answer.

As multiple people in the comments suggested, you are probably missing a using directive. More specifically using System;.

Hope this helps future programmers find the solution quicker.

like image 81
Jee Avatar answered Oct 14 '22 19:10

Jee