1. 程式人生 > >Purchasing: the name StandardPurchasingModule does not exist in current context.

Purchasing: the name StandardPurchasingModule does not exist in current context.

 The name StandardPurchasingModule.Instance does not exist in current context. The type or namespace IAppleExtensions could not be found
首先是報錯內容,由於某種原因我需要開啟一個別人壓縮後的工程,在開啟工程後出現了一些報錯。具體的報錯內容如下:

      error CS0246: The type or namespace name `IStoreListener' could not be found. Are you missing an assembly reference?

已知:對方給到的工程是成熟且完整的,在unity版本相同的情況下,排除環境照成的差異,那麼真相只有一個:本地設定有問題。  

 


IStoreListener是什麼呢,經過研究發現,此介面是unity自帶的程式集UnityEngine.Purchasing下的。此程式集通過dll載入,但是在報錯的工程中沒有在對應的解決方案下發現UnityEngine.Purchasing的引用。

如圖所示,該指令碼所屬的解決方案下並沒有出現UnityEngine.Purchasing的引用。
此問題困擾我多時,重安裝unity,嘗試不破解unity,和刪除Library和Temp重新生成解決方案等都沒有效果後,我又把目標鎖定在UnityEngine.Purchasing這個為何沒有生效的問題。


解決過程:

通過Google後(//遇事不決問股溝)發現了有人遇到了同樣的問題。為了避免誤人子弟這裡貼出原帖(https://forum.unity.com/threads/purchasing-the-name-standardpurchasingmodule-does-not-exist-in-current-context.457131/)此老哥解決了我的問題。
具體是在

 

下,開啟IN-APP PURCHASING就可以了。然後Enable,此問題得到解決。


當然如果遇到此問題,根據原帖也可能是IAP出錯,需要重新從官網下載IAP重新匯入就可以了。
希望能夠幫到下一個我。