Android IAP: Check for singleton before getting

Fixes #273, fixes #212, fixes #godotengine/godot#22082.
This commit is contained in:
Rémi Verschelde
2018-09-14 22:57:19 +02:00
parent 471b813911
commit 5b01dccc82

View File

@@ -15,9 +15,14 @@ signal consume_not_required
signal sku_details_complete
signal sku_details_error
onready var payment = Engine.get_singleton("GodotPayments")
var payment
func _ready():
if Engine.has_singleton("GodotPayment"):
payment = Engine.get_singleton("GodotPayments")
else:
print("GodotPayment singleton is only available on Android devices.")
if payment:
# set callback with this script instance
payment.setPurchaseCallbackId(get_instance_id())