当前上下文中不存在名称为`Array`的内容。

12

有人知道我为什么会收到这个错误吗?这是在将我的项目升级到新版本的Unity3d之后出现的。

Error CS0103:当前上下文中不存在“Array”名称

#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

5
你可能缺少一个 "using" 指令。 - captainCrazy
7
正如captainCrazy所说,检查你是否有写 using System; - Georg Patscheider
谢谢大家,问题已经解决了。 - mhart ian cruz
遇到了同样的问题,感谢你提供了解决方案! - Dave B
1个回答

12

我来晚了,但是我想要提供官方答案。

正如评论中多位用户所建议的那样,你可能缺少了一个 using 指令。更具体地说是 using System;

希望这能帮助未来的程序员更快地找到解决方案。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接