func _ready(): var request := ConsentRequestParameters.new()
request.tag_for_under_age_of_consent = false
UserMessagingPlatform.consent_information.update(request, _on_consent_info_updated_success, _on_consent_info_updated_failure)
func _on_consent_info_updated_success(): if UserMessagingPlatform.consent_information.get_is_consent_form_available(): load_form()
func _on_consent_info_updated_failure(form_error : FormError): pass
func load_form(): UserMessagingPlatform.load_consent_form(_on_consent_form_load_success, _on_consent_form_load_failure)
func _on_consent_form_load_success(consent_form : ConsentForm): _consent_form = consent_form if UserMessagingPlatform.consent_information.get_consent_status() == UserMessagingPlatform.consent_information.ConsentStatus.REQUIRED: consent_form.show(_on_consent_form_dismissed)
func _on_consent_form_load_failure(form_error : FormError): pass
func _on_consent_form_dismissed(form_error : FormError): if UserMessagingPlatform.consent_information.get_consent_status() == UserMessagingPlatform.consent_information.ConsentStatus.OBTAINED: pass # Handle dismissal by reloading form load_form()
var _ad_view : AdView
func _ready():
MobileAds.initialize()
func _create_ad_view() -> void:
if _ad_view:
destroy_ad_view()
var unit_id : String if OS.get_name() == "Android": unit_id = "ca-app-pub-XXXXXXXXXXX/XXXXXXXXXXX" elif OS.get_name() == "iOS": unit_id = "ca-app-pub-XXXXXXXXXXX/XXXXXXXXXXX" var ad_size = AdSize.new(350, 50) #広告の大きさ _ad_view = AdView.new(unit_id, ad_size, AdPosition.Values.TOP) #広告のポジション var ad_request = AdRequest.new() _ad_view.load_ad(ad_request) func destroy_ad_view() -> void:
if _ad_view:
_ad_view.destroy()
_ad_view = null
var _rewarded_ad : RewardedAdvar on_user_earned_reward_listener := OnUserEarnedRewardListener.new()
func _ready(): on_user_earned_reward_listener.on_user_earned_reward = func(rewarded_item : RewardedItem): # ここに報酬のコードを書く
# _on_load_pressedを読んで広告を開始するfunc _on_load_pressed(): if _rewarded_ad: _rewarded_ad.destroy() _rewarded_ad = null
var unit_id : String if OS.get_name() == "Android": unit_id = "ca-app-pub-XXXXXXXXXX/XXXXXXXXXX" elif OS.get_name() == "iOS": unit_id = "ca-app-pub-XXXXXXXXXX/XXXXXXXXXX"
var rewarded_ad_load_callback := RewardedAdLoadCallback.new() rewarded_ad_load_callback.on_ad_failed_to_load = func(adError : LoadAdError) -> void: print(adError.message)
rewarded_ad_load_callback.on_ad_loaded = func(rewarded_ad : RewardedAd) -> void: print("rewarded ad loaded" + str(rewarded_ad._uid)) _rewarded_ad = rewarded_ad _rewarded_ad.show(on_user_earned_reward_listener)
RewardedAdLoader.new().load(unit_id, AdRequest.new(), rewarded_ad_load_callback)
chmod +x update_and_install.sh./update_and_install.sh