- Home /
Unity IAP Button: NullReferenceException: Object reference not set to an instance of an object
So I was using the IAP button as the tutorial showed me and the button won't work ingame only giving me this error:
NullReferenceException: Object reference not set to an instance of an object UnityEngine.Purchasing.UIFakeStore.InstantiateDialog () (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/UIFakeStore.cs:175) UnityEngine.Purchasing.UIFakeStore.StartUI (System.String queryText, System.String okayButtonText, System.String cancelButtonText, System.Collections.Generic.List`1[T] options, System.Action`2[T1,T2] callback) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/UIFakeStore.cs:153) UnityEngine.Purchasing.UIFakeStore.StartUI[T] (System.Object model, UnityEngine.Purchasing.FakeStore+DialogType dialogType, System.Action`2[T1,T2] callback) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/UIFakeStore.cs:128) UnityEngine.Purchasing.FakeStore.FakePurchase (UnityEngine.Purchasing.ProductDefinition product, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/FakeStore.cs:163) UnityEngine.Purchasing.FakeStore.Purchase (System.String productJSON, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/FakeStore/FakeStore.cs:132) UnityEngine.Purchasing.JSONStore.Purchase (UnityEngine.Purchasing.ProductDefinition product, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Stores/BaseStore/JSONStore.cs:354) UnityEngine.Purchasing.PurchasingManager.InitiatePurchase (UnityEngine.Purchasing.Product product, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Purchasing/PurchasingManager.cs:60) UnityEngine.Purchasing.PurchasingManager.InitiatePurchase (System.String purchasableId, System.String developerPayload) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Purchasing/PurchasingManager.cs:69) UnityEngine.Purchasing.PurchasingManager.InitiatePurchase (System.String productId) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Purchasing/PurchasingManager.cs:43) UnityEngine.Purchasing.CodelessIAPStoreListener.InitiatePurchase (System.String productID) (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Codeless/CodelessIAPStoreListener.cs:145) UnityEngine.Purchasing.IAPButton.PurchaseProduct () (at Library/PackageCache/com.unity.purchasing@3.0.1/Runtime/Codeless/IAPButton.cs:108) UnityEngine.Events.InvokableCall.Invoke () (at :0) UnityEngine.Events.UnityEvent.Invoke () (at :0) UnityEngine.UI.Button.Press () (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261) UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Games/2020.1.5f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)
I know the generic problem with NullReferenceException but I just don't understand this.
Answer by ISLAMMOHY · Mar 14, 2021 at 04:07 AM
Same here, did you find any solution?
Yes. You need to download the sample file too because it has the prefab for it. For some reason the main file 3.0 or something like that doesn't contain the UIFakeStoreCanvas prefab. In the package manager find In App Purchases then check for versions. Update it for the latest if you didn't already then download the sample.
Your answer
Follow this Question
Related Questions
Consume a non consumable after loading product 0 Answers
UnityIAP Android Failed Purchase NoConsumible between two device 0 Answers
Android IAP Cannot confirm purchase due to missing transaction id 3 Answers
NullReference in Start() or Awake() when testing on Android device, works fine in Editor 2 Answers
how to implement IAP subscription??? 0 Answers