This commit is contained in:
Yadciel
2022-11-24 16:00:50 +01:00
parent 6ca7cd7650
commit 46fbe6685b
120 changed files with 4206 additions and 0 deletions

View File

@ -0,0 +1,299 @@
using Godot;
using System;
using System.Collections;
public class Example : Control
{
private Node MobileAds;
IDictionary config;
private Button EnableBanner;
private Button DisableBanner;
private Button ShowBanner;
private Button HideBanner;
private Button Interstitial;
private Button Rewarded;
private Button RewardedInterstitial;
private Button RequestUserConsent;
private Button ResetConsentState;
private RichTextLabel Advice;
private AudioStreamPlayer Music;
private CheckBox BannerPosition;
private ItemList BannerSizes;
private void GetAllNodes()
{
MobileAds = (Node) GetNode("/root/MobileAds");
config = (IDictionary) MobileAds.Get("config");
EnableBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner/EnableBanner");
DisableBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner/DisableBanner");
ShowBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner2/ShowBanner");
HideBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner2/HideBanner");
Interstitial = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Interstitial");
Rewarded = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Rewarded");
RewardedInterstitial = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/RewardedInterstitial");
RequestUserConsent = (Button) GetNode("Background/TabContainer/UMP/VBoxContainer/RequestUserConsent");
ResetConsentState = (Button) GetNode("Background/TabContainer/UMP/VBoxContainer/ResetConsentState");
Advice = (RichTextLabel) GetNode("Background/Advice");
Music = (AudioStreamPlayer) GetNode("Music");
BannerPosition = (CheckBox) GetNode("Background/TabContainer/Banner/VBoxContainer/Position");
BannerSizes = (ItemList) GetNode("Background/TabContainer/Banner/VBoxContainer/BannerSizes");
}
private void _add_text_Advice_Node(String text_value)
{
Advice.BbcodeText += text_value + "\n";
}
public override void _Ready()
{
GetAllNodes();
OS.CenterWindow();
Music.Play();
foreach(String banner_size in (IEnumerable) ((Godot.Object)MobileAds.Get("AdMobSettings")).Get("BANNER_SIZE"))
{
BannerSizes.AddItem(banner_size);
}
if (OS.GetName() == "Android" || OS.GetName() == "iOS"){
BannerPosition.Pressed = Convert.ToBoolean(((IDictionary) config["banner"])["position"]);
MobileAds.Call("request_user_consent");
MobileAds.Connect("consent_info_update_failure", this, nameof(_on_MobileAds_consent_info_update_failure));
MobileAds.Connect("consent_status_changed", this, nameof(_on_MobileAds_consent_status_changed));
MobileAds.Connect("banner_loaded", this, nameof(_on_MobileAds_banner_loaded));
MobileAds.Connect("banner_destroyed", this, nameof(_on_MobileAds_banner_destroyed));
MobileAds.Connect("interstitial_loaded", this, nameof(_on_MobileAds_interstitial_loaded));
MobileAds.Connect("interstitial_closed", this, nameof(_on_MobileAds_interstitial_closed));
MobileAds.Connect("rewarded_ad_loaded", this, nameof(_on_MobileAds_rewarded_ad_loaded));
MobileAds.Connect("rewarded_ad_closed", this, nameof(_on_MobileAds_rewarded_ad_closed));
MobileAds.Connect("rewarded_interstitial_ad_loaded", this, nameof(_on_MobileAds_rewarded_interstitial_ad_loaded));
MobileAds.Connect("rewarded_interstitial_ad_closed", this, nameof(_on_MobileAds_rewarded_interstitial_ad_closed));
MobileAds.Connect("user_earned_rewarded", this, nameof(_on_MobileAds_user_earned_rewarded));
MobileAds.Connect("initialization_complete", this, nameof(_on_MobileAds_initialization_complete));
}
else
{
_add_text_Advice_Node("AdMob only works on Android or iOS devices!");
}
}
private void _on_MobileAds_initialization_complete(int status, String _adapter_name)
{
if (status == (int)((IDictionary) ((Godot.Object)MobileAds.Get("AdMobSettings")).Get("INITIALIZATION_STATUS"))["READY"])
{
MobileAds.Call("load_interstitial");
MobileAds.Call("load_rewarded");
MobileAds.Call("load_rewarded_interstitial");
_add_text_Advice_Node("AdMob initialized on C#! With parameters:");
_add_text_Advice_Node("is_for_child_directed_treatment: " + ((IDictionary) config["general"])["is_for_child_directed_treatment"].ToString());
_add_text_Advice_Node("is_test_europe_user_consent: " + ((IDictionary) config["general"])["is_test_europe_user_consent"].ToString());
_add_text_Advice_Node("max_ad_content_rating: " + ((IDictionary) config["general"])["max_ad_content_rating"].ToString());
_add_text_Advice_Node("instance_id: " + GetInstanceId().ToString());
EnableBanner.Disabled = false;
BannerPosition.Disabled = false;
RequestUserConsent.Disabled = false;
ResetConsentState.Disabled = false;
}
else
{
_add_text_Advice_Node("AdMob not initialized, check your configuration");
}
_add_text_Advice_Node("---------------------------------------------------");
}
private void _on_MobileAds_interstitial_loaded()
{
_add_text_Advice_Node("Interstitial loaded");
Interstitial.Disabled = false;
}
private void _on_MobileAds_interstitial_closed()
{
MobileAds.Call("load_interstitial");
_add_text_Advice_Node("Interstitial closed");
}
private void _on_Interstitial_pressed()
{
MobileAds.Call("show_interstitial");
Interstitial.Disabled = true;
}
private void reset_banner_buttons()
{
DisableBanner.Disabled = true;
EnableBanner.Disabled = false;
ShowBanner.Disabled = true;
HideBanner.Disabled = true;
}
private void _on_MobileAds_banner_destroyed()
{
reset_banner_buttons();
_add_text_Advice_Node("Banner destroyed");
}
private void _on_MobileAds_banner_loaded()
{
DisableBanner.Disabled = false;
EnableBanner.Disabled = true;
ShowBanner.Disabled = false;
HideBanner.Disabled = false;
_add_text_Advice_Node("Banner loaded");
_add_text_Advice_Node("Banner width: " + MobileAds.Call("get_banner_width"));
_add_text_Advice_Node("Banner height: " + MobileAds.Call("get_banner_height"));
_add_text_Advice_Node("Banner width in pixels: " + MobileAds.Call("get_banner_width_in_pixels"));
_add_text_Advice_Node("Banner height in pixels: " + MobileAds.Call("get_banner_height_in_pixels"));
}
private void _on_EnableBanner_pressed()
{
EnableBanner.Disabled = true;
MobileAds.Call("load_banner");
}
private void _on_DisableBanner_pressed()
{
DisableBanner.Disabled = true;
EnableBanner.Disabled = false;
MobileAds.Call("destroy_banner");
}
private void _on_Rewarded_pressed()
{
MobileAds.Call("show_rewarded");
Rewarded.Disabled = true;
}
private void _on_RewardedInterstitial_pressed()
{
MobileAds.Call("show_rewarded_interstitial");
RewardedInterstitial.Disabled = true;
}
private void _on_MobileAds_rewarded_ad_loaded()
{
_add_text_Advice_Node("Rewarded ad loaded");
Rewarded.Disabled = false;
}
private void _on_MobileAds_rewarded_ad_closed()
{
MobileAds.Call("load_rewarded");
_add_text_Advice_Node("Rewarded ad closed");
}
private void _on_MobileAds_rewarded_interstitial_ad_loaded()
{
_add_text_Advice_Node("Rewarded Interstitial ad loaded");
RewardedInterstitial.Disabled = false;
}
private void _on_MobileAds_rewarded_interstitial_ad_closed()
{
MobileAds.Call("load_rewarded_interstitial");
_add_text_Advice_Node("Rewarded Interstitial ad closed");
}
private void _on_MobileAds_user_earned_rewarded(String currency, int amount)
{
Advice.BbcodeText += "EARNED " + currency + " with amount: " + amount.ToString() + "\n";
}
private void _on_MobileAds_consent_info_update_failure(int _error_code, String error_message)
{
_add_text_Advice_Node("Request Consent from European Users failure: " + error_message);
_add_text_Advice_Node("---------------------------------------------------");
}
private void _on_MobileAds_consent_status_changed(String status_message)
{
_add_text_Advice_Node(status_message);
}
private void _on_BannerSizes_item_selected(int index)
{
if ((bool) MobileAds.Call("get_is_initialized"))
{
String item_text = (String) BannerSizes.GetItemText(index);
((IDictionary)config["banner"])["size"] = index;
_add_text_Advice_Node("Banner Size changed:" + item_text);
if ((bool) MobileAds.Call("get_is_banner_loaded"))
{
MobileAds.Call("load_banner");
}
}
}
private void _on_ResetConsentState_pressed()
{
MobileAds.Call("reset_consent_state", true);
}
private void _on_RequestUserConsent_pressed()
{
MobileAds.Call("request_user_consent");
}
private void _on_Position_pressed()
{
((IDictionary)config["banner"])["position"] = BannerPosition.Pressed;
if ((bool)MobileAds.Call("get_is_banner_loaded"))
{
MobileAds.Call("load_banner");
}
}
private void _on_IsInitialized_pressed()
{
_add_text_Advice_Node("Is initialized: " + MobileAds.Call("get_is_initialized"));
}
private void _on_IsBannerLoaded_pressed()
{
_add_text_Advice_Node("Is Banner loaded: " + MobileAds.Call("get_is_banner_loaded"));
}
private void _on_IsInterstitialLoaded_pressed()
{
_add_text_Advice_Node("Is Interstitial loaded: " + MobileAds.Call("get_is_interstitial_loaded"));
}
private void _on_IsRewardedLoaded_pressed(){
_add_text_Advice_Node("Is Rewarded loaded: " + MobileAds.Call("get_is_rewarded_loaded"));
}
private void _on_IsRewardedInterstitialLoaded_pressed(){
_add_text_Advice_Node("Is RewardedInterstitial loaded: " + MobileAds.Call("get_is_rewarded_interstitial_loaded"));
}
private void _on_ShowBanner_pressed()
{
MobileAds.Call("show_banner");
}
private void _on_HideBanner_pressed()
{
MobileAds.Call("hide_banner");
}
}

View File

@ -0,0 +1,299 @@
extends Control
onready var EnableBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner/EnableBanner
onready var DisableBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner/DisableBanner
onready var ShowBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner2/ShowBanner
onready var HideBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner2/HideBanner
onready var Interstitial : Button = $Background/TabContainer/AdFormats/VBoxContainer/Interstitial
onready var Rewarded : Button = $Background/TabContainer/AdFormats/VBoxContainer/Rewarded
onready var RewardedInterstitial : Button = $Background/TabContainer/AdFormats/VBoxContainer/RewardedInterstitial
onready var RequestUserConsent : Button = $Background/TabContainer/UMP/VBoxContainer/RequestUserConsent
onready var ResetConsentState : Button = $Background/TabContainer/UMP/VBoxContainer/ResetConsentState
onready var Advice : RichTextLabel = $Background/Advice
onready var BannerPosition : CheckBox = $Background/TabContainer/Banner/VBoxContainer/Position
onready var RespectSafeArea : CheckBox = $Background/TabContainer/Banner/VBoxContainer/RespectSafeArea
onready var BannerSizes : ItemList = $Background/TabContainer/Banner/VBoxContainer/BannerSizes
func _add_text_Advice_Node(text_value : String) -> void:
Advice.bbcode_text += text_value + "\n"
func _ready() -> void:
BannerPosition.pressed = MobileAds.AdMobSettings.config.banner.position
RespectSafeArea.pressed = MobileAds.AdMobSettings.config.banner.respect_safe_area
OS.center_window()
for banner_size in MobileAds.AdMobSettings.BANNER_SIZE:
BannerSizes.add_item(banner_size)
if OS.get_name() == "Android" or OS.get_name() == "iOS":
# warning-ignore:return_value_discarded
MobileAds.connect("consent_form_dismissed", self, "_on_MobileAds_consent_form_dismissed")
# warning-ignore:return_value_discarded
MobileAds.connect("consent_form_load_failure", self, "_on_MobileAds_consent_form_load_failure")
# warning-ignore:return_value_discarded
MobileAds.connect("consent_info_update_failure", self, "_on_MobileAds_consent_info_update_failure")
# warning-ignore:return_value_discarded
MobileAds.connect("consent_info_update_success", self, "_on_MobileAds_consent_info_update_success")
# warning-ignore:return_value_discarded
MobileAds.connect("consent_status_changed", self, "_on_MobileAds_consent_status_changed")
# warning-ignore:return_value_discarded
MobileAds.connect("banner_loaded", self, "_on_MobileAds_banner_loaded")
# warning-ignore:return_value_discarded
MobileAds.connect("banner_destroyed", self, "_on_MobileAds_banner_destroyed")
# warning-ignore:return_value_discarded
MobileAds.connect("banner_clicked", self, "_on_MobileAds_banner_clicked")
# warning-ignore:return_value_discarded
MobileAds.connect("banner_closed", self, "_on_MobileAds_banner_closed")
# warning-ignore:return_value_discarded
MobileAds.connect("banner_failed_to_load", self, "_on_MobileAds_banner_failed_to_load")
# warning-ignore:return_value_discarded
MobileAds.connect("banner_recorded_impression", self, "_on_MobileAds_banner_recorded_impression")
# warning-ignore:return_value_discarded
MobileAds.connect("interstitial_loaded", self, "_on_MobileAds_interstitial_loaded")
# warning-ignore:return_value_discarded
MobileAds.connect("interstitial_closed", self, "_on_MobileAds_interstitial_closed")
# warning-ignore:return_value_discarded
MobileAds.connect("interstitial_clicked", self, "_on_MobileAds_interstitial_clicked")
# warning-ignore:return_value_discarded
MobileAds.connect("interstitial_failed_to_load", self, "_on_MobileAds_interstitial_failed_to_load")
# warning-ignore:return_value_discarded
MobileAds.connect("interstitial_failed_to_show", self, "_on_MobileAds_interstitial_failed_to_show")
# warning-ignore:return_value_discarded
MobileAds.connect("interstitial_opened", self, "_on_MobileAds_interstitial_opened")
# warning-ignore:return_value_discarded
MobileAds.connect("interstitial_recorded_impression", self, "_on_MobileAds_interstitial_recorded_impression")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_ad_loaded", self, "_on_MobileAds_rewarded_ad_loaded")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_ad_closed", self, "_on_MobileAds_rewarded_ad_closed")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_ad_clicked", self, "_on_MobileAds_rewarded_ad_clicked")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_ad_failed_to_load", self, "_on_MobileAds_rewarded_ad_failed_to_load")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_ad_failed_to_show", self, "_on_MobileAds_rewarded_ad_failed_to_show")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_ad_opened", self, "_on_MobileAds_rewarded_ad_opened")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_ad_recorded_impression", self, "_on_MobileAds_rewarded_ad_recorded_impression")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_interstitial_ad_loaded", self, "_on_MobileAds_rewarded_interstitial_ad_loaded")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_interstitial_ad_closed", self, "_on_MobileAds_rewarded_interstitial_ad_closed")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_interstitial_ad_clicked", self, "_on_MobileAds_rewarded_interstitial_ad_clicked")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_interstitial_ad_failed_to_load", self, "_on_MobileAds_rewarded_interstitial_ad_failed_to_load")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_interstitial_ad_failed_to_show", self, "_on_MobileAds_rewarded_interstitial_ad_failed_to_show")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_interstitial_ad_opened", self, "_on_MobileAds_rewarded_interstitial_ad_opened")
# warning-ignore:return_value_discarded
MobileAds.connect("rewarded_interstitial_ad_recorded_impression", self, "_on_MobileAds_rewarded_interstitial_ad_recorded_impression")
# warning-ignore:return_value_discarded
MobileAds.connect("user_earned_rewarded", self, "_on_MobileAds_user_earned_rewarded")
# warning-ignore:return_value_discarded
MobileAds.connect("initialization_complete", self, "_on_MobileAds_initialization_complete")
else:
_add_text_Advice_Node("AdMob only works on Android or iOS devices!")
func _on_MobileAds_rewarded_interstitial_ad_clicked():
_add_text_Advice_Node("Rewarded Interstitial clicked")
func _on_MobileAds_rewarded_interstitial_ad_failed_to_load(error_code):
_add_text_Advice_Node("Rewarded Interstitial failed to load, error_code = " + str(error_code))
func _on_MobileAds_rewarded_interstitial_ad_failed_to_show(error_code):
_add_text_Advice_Node("Rewarded Interstitial failed to show, error_code = " + str(error_code))
func _on_MobileAds_rewarded_interstitial_ad_opened():
_add_text_Advice_Node("Rewarded Interstitial opened")
func _on_MobileAds_rewarded_interstitial_ad_recorded_impression():
_add_text_Advice_Node("Rewarded Interstitial recorded impression")
func _on_MobileAds_rewarded_ad_clicked():
_add_text_Advice_Node("Rewarded clicked")
func _on_MobileAds_rewarded_ad_failed_to_load(error_code):
_add_text_Advice_Node("Rewarded failed to load, error_code = " + str(error_code))
func _on_MobileAds_rewarded_ad_failed_to_show(error_code):
_add_text_Advice_Node("Rewarded failed to show, error_code = " + str(error_code))
func _on_MobileAds_rewarded_ad_opened():
_add_text_Advice_Node("Rewarded opened")
func _on_MobileAds_rewarded_ad_recorded_impression():
_add_text_Advice_Node("Rewarded recorded impression")
func _on_MobileAds_interstitial_clicked():
_add_text_Advice_Node("Interstitial clicked")
func _on_MobileAds_interstitial_failed_to_load(error_code):
_add_text_Advice_Node("Interstitial failed to load, error_code = " + str(error_code))
func _on_MobileAds_interstitial_failed_to_show(error_code):
_add_text_Advice_Node("Interstitial failed to show, error_code = " + str(error_code))
func _on_MobileAds_interstitial_opened():
_add_text_Advice_Node("Interstitial opened")
func _on_MobileAds_interstitial_recorded_impression():
_add_text_Advice_Node("Interstitial recorded impression")
func _on_MobileAds_banner_clicked():
_add_text_Advice_Node("Banner clicked")
func _on_MobileAds_banner_closed():
_add_text_Advice_Node("Banner closed")
func _on_MobileAds_banner_failed_to_load(error_code):
_add_text_Advice_Node("Banner failed to load, error_code = " + str(error_code))
func _on_MobileAds_banner_recorded_impression():
_add_text_Advice_Node("Banner recorded impression")
func _on_MobileAds_initialization_complete(status : int, adapter_name : String) -> void:
if status == MobileAds.AdMobSettings.INITIALIZATION_STATUS.READY:
MobileAds.load_interstitial()
MobileAds.load_rewarded()
MobileAds.load_rewarded_interstitial()
_add_text_Advice_Node("AdMob initialized on GDScript! With parameters:")
_add_text_Advice_Node(JSON.print(MobileAds.config, "\t"))
_add_text_Advice_Node("instance_id: " + str(get_instance_id()))
EnableBanner.disabled = false
BannerPosition.disabled = false
RequestUserConsent.disabled = false
ResetConsentState.disabled = false
else:
_add_text_Advice_Node("AdMob not initialized, check your configuration")
_add_text_Advice_Node("---------------------------------------------------")
func _on_MobileAds_interstitial_loaded() -> void:
Interstitial.disabled = false
_add_text_Advice_Node("Interstitial loaded")
func _on_MobileAds_interstitial_closed() -> void:
MobileAds.load_interstitial()
_add_text_Advice_Node("Interstitial closed")
func _on_Interstitial_pressed() -> void:
MobileAds.show_interstitial()
Interstitial.disabled = true
func reset_banner_buttons() -> void:
DisableBanner.disabled = true
EnableBanner.disabled = false
ShowBanner.disabled = true
HideBanner.disabled = true
func _on_MobileAds_banner_destroyed() -> void:
reset_banner_buttons()
_add_text_Advice_Node("Banner destroyed")
func _on_MobileAds_banner_loaded() -> void:
DisableBanner.disabled = false
EnableBanner.disabled = true
ShowBanner.disabled = false
HideBanner.disabled = false
_add_text_Advice_Node("Banner loaded")
_add_text_Advice_Node("Banner width: " + str(MobileAds.get_banner_width()))
_add_text_Advice_Node("Banner height: " + str(MobileAds.get_banner_height()))
_add_text_Advice_Node("Banner width in pixels: " + str(MobileAds.get_banner_width_in_pixels()))
_add_text_Advice_Node("Banner height in pixels: " + str(MobileAds.get_banner_height_in_pixels()))
func _on_EnableBanner_pressed() -> void:
EnableBanner.disabled = true
MobileAds.load_banner()
func _on_DisableBanner_pressed() -> void:
DisableBanner.disabled = true
EnableBanner.disabled = false
MobileAds.destroy_banner()
func _on_Rewarded_pressed() -> void:
MobileAds.show_rewarded()
Rewarded.disabled = true
func _on_RewardedInterstitial_pressed() -> void:
MobileAds.show_rewarded_interstitial()
RewardedInterstitial.disabled = true
func _on_MobileAds_rewarded_ad_loaded() -> void:
Rewarded.disabled = false
_add_text_Advice_Node("Rewarded ad loaded")
func _on_MobileAds_rewarded_ad_closed() -> void:
MobileAds.load_rewarded()
_add_text_Advice_Node("Rewarded ad closed")
func _on_MobileAds_rewarded_interstitial_ad_loaded() -> void:
RewardedInterstitial.disabled = false
_add_text_Advice_Node("Rewarded Interstitial ad loaded")
func _on_MobileAds_rewarded_interstitial_ad_closed() -> void:
MobileAds.load_rewarded_interstitial()
_add_text_Advice_Node("Rewarded Interstitial ad closed")
func _on_MobileAds_user_earned_rewarded(currency : String, amount : int) -> void:
Advice.bbcode_text += "EARNED " + currency + " with amount: " + str(amount) + "\n"
func _on_MobileAds_consent_form_dismissed() -> void:
_add_text_Advice_Node("Request Consent from European Users Form dismissed")
func _on_MobileAds_consent_form_load_failure(error_code, error_message) -> void:
_add_text_Advice_Node("Request Consent from European Users load_failure: " + error_message)
_add_text_Advice_Node("---------------------------------------------------")
func _on_MobileAds_consent_info_update_failure(_error_code : int, error_message : String) -> void:
_add_text_Advice_Node("Request Consent from European Users update failure: " + error_message)
_add_text_Advice_Node("---------------------------------------------------")
func _on_MobileAds_consent_info_update_success(status_message : String) -> void:
_add_text_Advice_Node("Consent info update success: " + status_message)
func _on_MobileAds_consent_status_changed(status_message : String) -> void:
_add_text_Advice_Node("Consent status changed: " + status_message)
func _on_BannerSizes_item_selected(index : int) -> void:
if MobileAds.get_is_initialized():
var item_text : String = BannerSizes.get_item_text(index)
MobileAds.config.banner.size = item_text
_add_text_Advice_Node("Banner Size changed:" + item_text)
if MobileAds.get_is_banner_loaded():
MobileAds.load_banner()
func _on_ResetConsentState_pressed() -> void:
MobileAds.reset_consent_state(true)
func _on_RequestUserConsent_pressed() -> void:
MobileAds.request_user_consent()
func _on_Position_pressed() -> void:
MobileAds.config.banner.position = BannerPosition.pressed
if MobileAds.get_is_banner_loaded():
MobileAds.load_banner()
func _on_RespectSafeArea_pressed():
MobileAds.config.banner.respect_safe_area = RespectSafeArea.pressed
if MobileAds.get_is_banner_loaded():
MobileAds.load_banner()
func _on_IsInitialized_pressed() -> void:
_add_text_Advice_Node("Is initialized: " + str(MobileAds.get_is_initialized()))
func _on_IsBannerLoaded_pressed() -> void:
_add_text_Advice_Node("Is Banner loaded: " + str(MobileAds.get_is_banner_loaded()))
func _on_IsInterstitialLoaded_pressed() -> void:
_add_text_Advice_Node("Is Interstitial loaded: " + str(MobileAds.get_is_interstitial_loaded()))
func _on_IsRewardedLoaded_pressed() -> void:
_add_text_Advice_Node("Is Rewarded loaded: " + str(MobileAds.get_is_rewarded_loaded()))
func _on_IsRewardedInterstitialLoaded_pressed() -> void:
_add_text_Advice_Node("Is RewardedInterstitial loaded: " + str(MobileAds.get_is_rewarded_interstitial_loaded()))
func _on_ShowBanner_pressed() -> void:
MobileAds.show_banner()
func _on_HideBanner_pressed() -> void:
MobileAds.hide_banner()

View File

@ -0,0 +1,347 @@
[gd_scene load_steps=11 format=2]
[ext_resource path="res://addons/admob/test/Example.gd" type="Script" id=1]
[ext_resource path="res://addons/admob/assets/icon-500.png" type="Texture" id=2]
[ext_resource path="res://addons/admob/assets/poing.jpeg" type="Texture" id=3]
[ext_resource path="res://addons/admob/assets/music.ogg" type="AudioStream" id=4]
[ext_resource path="res://addons/admob/test/MusicCheckButton.gd" type="Script" id=5]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.36377, 0.23226, 0.0795746, 1 )
[sub_resource type="StyleBoxEmpty" id=2]
[sub_resource type="Theme" id=3]
TabContainer/styles/panel = SubResource( 2 )
[sub_resource type="StyleBoxFlat" id=4]
bg_color = Color( 0, 0, 0, 1 )
[sub_resource type="StyleBoxFlat" id=5]
bg_color = Color( 0, 0, 0, 1 )
[node name="Example" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="Background" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 1, 0.541176, 0, 1 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="Poing" type="TextureRect" parent="Background"]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -100.0
margin_top = -100.0
texture = ExtResource( 3 )
expand = true
stretch_mode = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AdMob" type="TextureRect" parent="Background"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -256.0
margin_top = -256.0
margin_right = 256.0
margin_bottom = 256.0
texture = ExtResource( 2 )
stretch_mode = 6
__meta__ = {
"_edit_lock_": true
}
[node name="Advice" type="RichTextLabel" parent="Background"]
anchor_top = 0.0933333
anchor_right = 1.0
anchor_bottom = 0.402222
custom_styles/normal = SubResource( 1 )
bbcode_enabled = true
bbcode_text = "[wave]"
scroll_following = true
__meta__ = {
"_edit_use_anchors_": true
}
[node name="TabContainer" type="TabContainer" parent="Background"]
anchor_left = 0.145
anchor_top = 0.546667
anchor_right = 0.855
anchor_bottom = 0.773333
theme = SubResource( 3 )
__meta__ = {
"_edit_use_anchors_": true
}
[node name="AdFormats" type="Tabs" parent="Background/TabContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 24.0
[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/AdFormats"]
anchor_right = 1.0
anchor_bottom = 1.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Banner" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"]
margin_top = 46.0
margin_right = 426.0
margin_bottom = 66.0
size_flags_vertical = 0
alignment = 1
[node name="EnableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"]
margin_right = 211.0
margin_bottom = 20.0
size_flags_horizontal = 3
disabled = true
text = "ENABLE BANNER"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="DisableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"]
margin_left = 215.0
margin_right = 426.0
margin_bottom = 20.0
size_flags_horizontal = 3
disabled = true
text = "DISABLE BANNER"
[node name="Banner2" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"]
margin_top = 70.0
margin_right = 426.0
margin_bottom = 90.0
size_flags_vertical = 0
alignment = 1
[node name="ShowBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"]
margin_right = 211.0
margin_bottom = 20.0
size_flags_horizontal = 3
disabled = true
text = "SHOW BANNER"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HideBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"]
margin_left = 215.0
margin_right = 426.0
margin_bottom = 20.0
size_flags_horizontal = 3
disabled = true
text = "HIDE BANNER"
[node name="Interstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
margin_top = 94.0
margin_right = 426.0
margin_bottom = 114.0
disabled = true
text = "INTERSTITIAL"
[node name="Rewarded" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
margin_top = 118.0
margin_right = 426.0
margin_bottom = 138.0
disabled = true
text = "REWARDED"
[node name="RewardedInterstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
margin_top = 142.0
margin_right = 426.0
margin_bottom = 162.0
disabled = true
text = "REWARDED INTERSTITIAL"
[node name="Banner" type="Tabs" parent="Background/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 24.0
[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/Banner"]
anchor_right = 1.0
anchor_bottom = 1.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Control" type="Control" parent="Background/TabContainer/Banner/VBoxContainer"]
margin_top = 58.0
margin_right = 355.0
margin_bottom = 68.0
rect_min_size = Vector2( 0, 10 )
[node name="Position" type="CheckBox" parent="Background/TabContainer/Banner/VBoxContainer"]
margin_top = 72.0
margin_right = 355.0
margin_bottom = 88.0
custom_styles/hover = SubResource( 4 )
custom_styles/pressed = SubResource( 4 )
custom_styles/normal = SubResource( 4 )
pressed = true
text = "Position on TOP"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RespectSafeArea" type="CheckBox" parent="Background/TabContainer/Banner/VBoxContainer"]
margin_top = 92.0
margin_right = 355.0
margin_bottom = 108.0
custom_styles/hover = SubResource( 4 )
custom_styles/pressed = SubResource( 4 )
custom_styles/normal = SubResource( 4 )
text = "Respect Safe Area (RECOMMENDED TRUE)"
[node name="BannerSizes" type="ItemList" parent="Background/TabContainer/Banner/VBoxContainer"]
margin_top = 112.0
margin_right = 355.0
margin_bottom = 121.0
auto_height = true
same_column_width = true
__meta__ = {
"_edit_use_anchors_": true
}
[node name="UMP" type="Tabs" parent="Background/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 24.0
[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/UMP"]
anchor_right = 1.0
anchor_bottom = 1.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RequestUserConsent" type="Button" parent="Background/TabContainer/UMP/VBoxContainer"]
margin_top = 67.0
margin_right = 355.0
margin_bottom = 87.0
disabled = true
text = "REQUEST USER CONSENT"
[node name="ResetConsentState" type="Button" parent="Background/TabContainer/UMP/VBoxContainer"]
margin_top = 91.0
margin_right = 355.0
margin_bottom = 111.0
disabled = true
text = "RESET CONSENT STATE"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="General" type="Tabs" parent="Background/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 24.0
[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/General"]
anchor_right = 1.0
anchor_bottom = 1.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="IsInitialized" type="Button" parent="Background/TabContainer/General/VBoxContainer"]
margin_top = 31.0
margin_right = 355.0
margin_bottom = 51.0
text = "is_initialized()"
[node name="IsBannerLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"]
margin_top = 55.0
margin_right = 355.0
margin_bottom = 75.0
text = "is_banner_loaded()"
[node name="IsInterstitialLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"]
margin_top = 79.0
margin_right = 355.0
margin_bottom = 99.0
text = "is_interstitial_loaded()"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="IsRewardedLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"]
margin_top = 103.0
margin_right = 355.0
margin_bottom = 123.0
text = "is_rewarded_loaded()"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="IsRewardedInterstitialLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"]
margin_top = 127.0
margin_right = 355.0
margin_bottom = 147.0
text = "is_rewarded_interstitial_loaded()"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MusicCheckButton" type="CheckButton" parent="Background"]
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = -110.0
margin_top = -84.0
margin_bottom = -44.0
custom_styles/hover = SubResource( 5 )
custom_styles/pressed = SubResource( 5 )
custom_styles/normal = SubResource( 5 )
pressed = true
text = "MUSIC"
script = ExtResource( 5 )
[node name="Music" type="AudioStreamPlayer" parent="Background/MusicCheckButton"]
stream = ExtResource( 4 )
[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner/EnableBanner" to="." method="_on_EnableBanner_pressed"]
[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner/DisableBanner" to="." method="_on_DisableBanner_pressed"]
[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner2/ShowBanner" to="." method="_on_ShowBanner_pressed"]
[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner2/HideBanner" to="." method="_on_HideBanner_pressed"]
[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Interstitial" to="." method="_on_Interstitial_pressed"]
[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Rewarded" to="." method="_on_Rewarded_pressed"]
[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/RewardedInterstitial" to="." method="_on_RewardedInterstitial_pressed"]
[connection signal="pressed" from="Background/TabContainer/Banner/VBoxContainer/Position" to="." method="_on_Position_pressed"]
[connection signal="pressed" from="Background/TabContainer/Banner/VBoxContainer/RespectSafeArea" to="." method="_on_RespectSafeArea_pressed"]
[connection signal="item_selected" from="Background/TabContainer/Banner/VBoxContainer/BannerSizes" to="." method="_on_BannerSizes_item_selected"]
[connection signal="pressed" from="Background/TabContainer/UMP/VBoxContainer/RequestUserConsent" to="." method="_on_RequestUserConsent_pressed"]
[connection signal="pressed" from="Background/TabContainer/UMP/VBoxContainer/ResetConsentState" to="." method="_on_ResetConsentState_pressed"]
[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsInitialized" to="." method="_on_IsInitialized_pressed"]
[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsBannerLoaded" to="." method="_on_IsBannerLoaded_pressed"]
[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsInterstitialLoaded" to="." method="_on_IsInterstitialLoaded_pressed"]
[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsRewardedLoaded" to="." method="_on_IsRewardedLoaded_pressed"]
[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsRewardedInterstitialLoaded" to="." method="_on_IsRewardedInterstitialLoaded_pressed"]
[connection signal="pressed" from="Background/MusicCheckButton" to="Background/MusicCheckButton" method="_on_MusicCheckButton_pressed"]

View File

@ -0,0 +1,7 @@
extends CheckButton
func _ready():
$Music.playing = pressed
func _on_MusicCheckButton_pressed():
$Music.playing = pressed