Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2026 Google LLC

using UnityEngine;
using GoogleMobileAds.Api;
using System.Collections.Generic;
Expand Down Expand Up @@ -28,5 +30,56 @@ private void SetTestDeviceIds()
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_request_configuration]
}

private void SetChildAgeTreatment()
{
// [START set_child_age_treatment]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
AgeRestrictedTreatment = AgeRestrictedTreatment.Child
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_child_age_treatment]
}
private void SetChildDirectedTreatment()
{
// [START set_child_directed_treatment]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
TagForChildDirectedTreatment = TagForChildDirectedTreatment.True
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_child_directed_treatment]
}

private void SetUnderAgeOfConsent()
{
// [START set_under_age_of_consent]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
TagForUnderAgeOfConsent = TagForUnderAgeOfConsent.True
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_under_age_of_consent]
}

private void SetMaxAdContentRating()
{
// [START set_max_ad_content_rating]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
MaxAdContentRating = MaxAdContentRating.G
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_max_ad_content_rating]
}

private void AddNetworkExtras()
{
// [START add_network_extras]
var adRequest = new AdRequest();
adRequest.Extras.Add("collapsible", "bottom");
// [END add_network_extras]
}
}
}
53 changes: 53 additions & 0 deletions samples/HelloWorld/Assets/Snippets/RequestConfigurationSnippets.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2026 Google LLC

using UnityEngine;
using GoogleMobileAds.Api;
using System.Collections.Generic;
Expand Down Expand Up @@ -28,5 +30,56 @@ private void SetTestDeviceIds()
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_request_configuration]
}

private void SetChildAgeTreatment()
{
// [START set_child_age_treatment]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
AgeRestrictedTreatment = AgeRestrictedTreatment.Child
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_child_age_treatment]
}
private void SetChildDirectedTreatment()
{
// [START set_child_directed_treatment]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
TagForChildDirectedTreatment = TagForChildDirectedTreatment.True
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_child_directed_treatment]
}

private void SetUnderAgeOfConsent()
{
// [START set_under_age_of_consent]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
TagForUnderAgeOfConsent = TagForUnderAgeOfConsent.True
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_under_age_of_consent]
}

private void SetMaxAdContentRating()
{
// [START set_max_ad_content_rating]
RequestConfiguration requestConfiguration = new RequestConfiguration
{
MaxAdContentRating = MaxAdContentRating.G
};
MobileAds.SetRequestConfiguration(requestConfiguration);
// [END set_max_ad_content_rating]
}

private void AddNetworkExtras()
{
// [START add_network_extras]
var adRequest = new AdRequest();
adRequest.Extras.Add("collapsible", "bottom");
// [END add_network_extras]
}
}
}