From package-guide
This skill should be used when the user asks to "add ads", "implement AdMob", "add rewarded ads", "integrate Google Mobile Ads", "add ad system", "implement rewarded video", "add consent manager", "set up UMP", or needs to implement any advertising system in a Unity project. Provides a complete implementation workflow for Google AdMob rewarded ads with clean architecture patterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/package-guide:unity-admobThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Implement a Google AdMob rewarded ad system with GDPR consent handling (UMP SDK).
Implement a Google AdMob rewarded ad system with GDPR consent handling (UMP SDK). The architecture uses a callback-based request pattern: callers pass reward/failure callbacks through an event, and AdManager handles the ad lifecycle transparently.
App Start
|
v
ConsentManager.RequestConsent()
|
v (consent complete)
MobileAds.Initialize()
|
v
LoadRewardedAd() <---- auto-reload after each show
|
v
_adReadyVariable = true
|
[User taps ad button] (only enabled when adReady == true)
|
v
Event.Raise(new AdRequest(onRewarded, onFailed))
|
v
AdManager.Show() --> OnUserEarnedReward --> request.OnRewarded()
--> OnAdFailed --> request.OnFailed()
Key Principles:
Import Google Mobile Ads Unity Plugin via .unitypackage or UPM.
Configure GoogleMobileAdsSettings asset with App IDs.
A plain C# class carrying callbacks:
using System;
public class AdRequest
{
public Action OnRewarded { get; }
public Action OnFailed { get; }
public AdRequest(Action onRewarded, Action onFailed = null)
{
OnRewarded = onRewarded;
OnFailed = onFailed;
}
}
Handles UMP SDK consent flow before ad initialization:
public class ConsentManager : MonoBehaviour
{
private Action _onConsentCompleted;
public void RequestConsent(Action onConsentCompleted)
{
_onConsentCompleted = onConsentCompleted;
#if UNITY_ANDROID || UNITY_IOS
var requestParameters = new ConsentRequestParameters();
ConsentInformation.Update(requestParameters, OnConsentInfoUpdated);
#else
_onConsentCompleted?.Invoke();
#endif
}
// ... platform-specific consent form handling
}
Core lifecycle:
Awake() - Set _adReadyVariable = falseStart() - Call _consentManager.RequestConsent(InitializeAds)OnEnable() - Subscribe to ad request eventOnDisable() - Unsubscribe from ad request eventCritical patterns:
InitializeAds() - MobileAds.Initialize(), then LoadRewardedAd()LoadRewardedAd() - Destroy old ad, set ready=false, load new oneHandleAdRequest(AdRequest) - Store request, call _rewardedAd.Show()_currentRequest.OnRewarded?.Invoke()Each caller (popup, button, etc.) needs:
_adReadyVariable for button enable/disableevent.Raise(new AdRequest(onSuccess, onFailure))In #else (non-mobile) blocks, simulate ad success:
#else
Debug.Log("[AdManager] Editor mode - simulating ad success.");
_currentRequest?.OnRewarded?.Invoke();
_currentRequest = null;
#endif
Set _adReadyVariable = true in editor mode so buttons are enabled.
Use test IDs during development:
#if UNITY_ANDROID
private const string AD_UNIT_ID = "ca-app-pub-3940256099942544/5224354917"; // Test
#elif UNITY_IOS
private const string AD_UNIT_ID = "ca-app-pub-3940256099942544/1712485313"; // Test
#endif
Pre-release: Replace with real Ad Unit IDs from AdMob console.
Configure Assets/GoogleMobileAds/Resources/GoogleMobileAdsSettings:
ca-app-pub-XXXXX~XXXXXca-app-pub-XXXXX~XXXXXImportant: App ID uses ~ (tilde), Ad Unit ID uses / (slash).
Document all SerializeField assignments, SOAP asset creation, and pre-release checklist.
Create ScriptableEvent<AdRequest> subclass. See references/implementation-patterns.md.
Use C# events or direct reference:
// Direct reference approach
adManager.ShowRewardedAd(new AdRequest(onReward, onFail));
// Or static event approach
AdManager.OnAdRequested?.Invoke(new AdRequest(onReward, onFail));
| Pitfall | Solution |
|---|---|
| Ad buttons active when no ad loaded | Gate buttons on _adReadyVariable.Value == true |
| Consent form blocks forever | Add timeout, invoke callback on error too |
| Ads don't work in Editor | Use #if UNITY_ANDROID || UNITY_IOS guards, simulate in else block |
| Mock ad panel blocks input | Set CanvasGroup blocksRaycasts = false and Image raycastTarget = false when hidden |
| Ad not reloading after show | Register OnAdFullScreenContentClosed to trigger LoadRewardedAd() |
| First ad takes long to load | Start loading in Start() via consent flow, not on first request |
references/implementation-patterns.md - Complete code templates with SOAP and non-SOAP variantsnpx claudepluginhub flashwade03/unity-dev-vibecoding-with-awesome-assets --plugin package-guideGuides integration of Playgama Bridge SDK into Unity/C# for WebGL game publishing across 20+ platforms with ads, IAP, leaderboards, social features.
Builds Unity games with optimized C# scripts, URP/HDRP rendering pipelines, asset management, performance profiling, and cross-platform deployment for Unity 6 LTS.
Builds high-performance Unity games with optimized C# scripts, modern rendering pipelines (URP/HDRP), and cross-platform deployment. Covers DOTS, Burst Compiler, profiling, and asset management.