Loading...
Loading...
Compare original and translation side by side
references/ios-setup.mdreferences/ios-setup.mdAssets > Mobile Dependency Resolver > Android Resolver > ResolveAssets > External Dependency Manager > Android Resolver > ResolveAssets > Mobile Dependency Resolver > iOS Resolver > Install CocoapodsAssets > External Dependency Manager > iOS Resolver > Install CocoapodsAssets/Plugins/Android/<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>Assets > Mobile Dependency Resolver > Android Resolver > ResolveAssets > External Dependency Manager > Android Resolver > ResolveAssets > Mobile Dependency Resolver > iOS Resolver > Install CocoapodsAssets > External Dependency Manager > iOS Resolver > Install CocoapodsAssets/Plugins/Android/<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>Note: This skill provides technical integration guidance, including for LevelPlay's privacy APIs. It is not legal advice, and it does not determine which laws apply to your app — that depends on your users, your data practices, and your distribution. Consult your own legal counsel, and refer to Regulation Advanced Settings for Unity for the authoritative LevelPlay documentation.
references/privacy-settings.mdusing Unity.Services.LevelPlay;
// true = user has granted consent, false = user has not consented
LevelPlayPrivacySettings.SetGDPRConsent(true);using Unity.Services.LevelPlay;
using System.Collections.Generic;
// Add an entry for each ad network you have installed
LevelPlayPrivacySettings.SetGDPRConsents(new Dictionary<string, bool> {
{ "UnityAds", true },
{ "IronSource", true }
// See references/privacy-settings.md for the full network key list
});using Unity.Services.LevelPlay;
LevelPlayPrivacySettings.SetCCPA(true); // User opted out of data saleusing Unity.Services.LevelPlay;
LevelPlayPrivacySettings.SetCOPPA(true); // Child-directed appLevelPlay.Init()references/privacy-settings.mdLevelPlay.Init()references/ios-setup.md注意:本技能提供技术集成指导,包括LevelPlay的隐私API相关内容。但这并非法律建议,也不决定哪些法律适用于你的应用——这取决于你的用户、数据实践和分发渠道。请咨询自己的法律顾问,并参考Unity监管高级设置获取LevelPlay的权威文档。
references/privacy-settings.mdusing Unity.Services.LevelPlay;
// true = 用户已授予同意,false = 用户未授予同意
LevelPlayPrivacySettings.SetGDPRConsent(true);using Unity.Services.LevelPlay;
using System.Collections.Generic;
// 为每个已安装的广告网络添加条目
LevelPlayPrivacySettings.SetGDPRConsents(new Dictionary<string, bool> {
{ "UnityAds", true },
{ "IronSource", true }
// 完整的网络密钥列表请参考references/privacy-settings.md
});using Unity.Services.LevelPlay;
LevelPlayPrivacySettings.SetCCPA(true); // 用户选择退出数据售卖using Unity.Services.LevelPlay;
LevelPlayPrivacySettings.SetCOPPA(true); // 面向儿童的应用LevelPlay.Init()references/privacy-settings.mdLevelPlay.Init()references/ios-setup.mdCS0246CS0246LevelPlayInitializer.csusing UnityEngine;
using Unity.Services.LevelPlay;
public class LevelPlayInitializer : MonoBehaviour
{
[SerializeField] private string appKey;
void Awake()
{
// Persist across scene loads so ads stay initialized
DontDestroyOnLoad(gameObject);
}
void Start()
{
// Register initialization callbacks
LevelPlay.OnInitSuccess += OnInitSuccess;
LevelPlay.OnInitFailed += OnInitFailed;
// Initialize the SDK with your App Key
LevelPlay.Init(appKey);
}
private void OnInitSuccess(LevelPlayConfiguration config)
{
Debug.Log("LevelPlay SDK initialized successfully");
// SDK is now ready to load ads
}
private void OnInitFailed(LevelPlayInitError error)
{
Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
}
void OnDestroy()
{
LevelPlay.OnInitSuccess -= OnInitSuccess;
LevelPlay.OnInitFailed -= OnInitFailed;
}
}Assets/Scripts/LevelPlayInitializer.csAssets/Scripts/Ads/LevelPlayInitializer.csStart()LevelPlay.Init(appKey)// MUST be registered BEFORE LevelPlay.Init() to avoid losing early impressions.
// Callback fires on a BACKGROUND thread — see references/ilrd-api.md for
// thread-safe forwarding patterns and a Firebase example.
LevelPlay.OnImpressionDataReady += OnImpressionDataReady;private void OnImpressionDataReady(LevelPlayImpressionData impressionData)
{
// See references/ilrd-api.md for full implementation.
// For now, just log so you can verify it fires:
Debug.Log($"ILRD: {impressionData.AdNetwork} / {impressionData.AdFormat} / ${impressionData.Revenue}");
}OnDestroy()LevelPlay.OnImpressionDataReady -= OnImpressionDataReady;references/ilrd-api.mdLevelPlayInitializer.csusing UnityEngine;
using Unity.Services.LevelPlay;
public class LevelPlayInitializer : MonoBehaviour
{
[SerializeField] private string appKey;
void Awake()
{
// Persist across scene loads so ads stay initialized
DontDestroyOnLoad(gameObject);
}
void Start()
{
// Register initialization callbacks
LevelPlay.OnInitSuccess += OnInitSuccess;
LevelPlay.OnInitFailed += OnInitFailed;
// Initialize the SDK with your App Key
LevelPlay.Init(appKey);
}
private void OnInitSuccess(LevelPlayConfiguration config)
{
Debug.Log("LevelPlay SDK initialized successfully");
// SDK is now ready to load ads
}
private void OnInitFailed(LevelPlayInitError error)
{
Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
}
void OnDestroy()
{
LevelPlay.OnInitSuccess -= OnInitSuccess;
LevelPlay.OnInitFailed -= OnInitFailed;
}
}Assets/Scripts/LevelPlayInitializer.csAssets/Scripts/Ads/LevelPlayInitializer.csStart()LevelPlay.Init(appKey)// MUST be registered BEFORE LevelPlay.Init() to avoid losing early impressions.
// Callback fires on a BACKGROUND thread — see references/ilrd-api.md for
// thread-safe forwarding patterns and a Firebase example.
LevelPlay.OnImpressionDataReady += OnImpressionDataReady;private void OnImpressionDataReady(LevelPlayImpressionData impressionData)
{
// See references/ilrd-api.md for full implementation.
// For now, just log so you can verify it fires:
Debug.Log($"ILRD: {impressionData.AdNetwork} / {impressionData.AdFormat} / ${impressionData.Revenue}");
}OnDestroy()LevelPlay.OnImpressionDataReady -= OnImpressionDataReady;references/ilrd-api.mdGameManager.csusing Unity.Services.LevelPlay;void Start()
{
// Register initialization callbacks
LevelPlay.OnInitSuccess += OnInitSuccess;
LevelPlay.OnInitFailed += OnInitFailed;
// Initialize the SDK - REPLACE with your actual App Key from Step 5
LevelPlay.Init("YOUR_APP_KEY_HERE");
// ... your other existing Start() code
}private void OnInitSuccess(LevelPlayConfiguration config)
{
Debug.Log("LevelPlay SDK initialized successfully");
// SDK is ready - you can now create ad objects
}
private void OnInitFailed(LevelPlayInitError error)
{
Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
}void OnDestroy()
{
// Unregister callbacks
LevelPlay.OnInitSuccess -= OnInitSuccess;
LevelPlay.OnInitFailed -= OnInitFailed;
}LevelPlay.Init(...)OnDestroy()"YOUR_APP_KEY_HERE"DontDestroyOnLoad(gameObject);Awake()GameManager.csusing Unity.Services.LevelPlay;void Start()
{
// Register initialization callbacks
LevelPlay.OnInitSuccess += OnInitSuccess;
LevelPlay.OnInitFailed += OnInitFailed;
// Initialize the SDK - REPLACE with your actual App Key from Step 5
LevelPlay.Init("YOUR_APP_KEY_HERE");
// ... your other existing Start() code
}private void OnInitSuccess(LevelPlayConfiguration config)
{
Debug.Log("LevelPlay SDK initialized successfully");
// SDK is ready - you can now create ad objects
}
private void OnInitFailed(LevelPlayInitError error)
{
Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
}void OnDestroy()
{
// Unregister callbacks
LevelPlay.OnInitSuccess -= OnInitSuccess;
LevelPlay.OnInitFailed -= OnInitFailed;
}LevelPlay.Init(...)OnDestroy()"YOUR_APP_KEY_HERE"Awake()DontDestroyOnLoad(gameObject);LevelPlayInitializer.csGameManager.csusing UnityEngine;
public class GameManager : MonoBehaviour
{
void Awake()
{
// Add LevelPlay initialization as a component
gameObject.AddComponent<LevelPlayInitializer>();
// ... your other initialization code
}
}LevelPlayInitializer.csGameManagerLevelPlayInitializer.Awake()DontDestroyOnLoad(gameObject)LevelPlayInitializer.csGameManagerLevelPlayInitializer.csGameManager.csusing UnityEngine;
public class GameManager : MonoBehaviour
{
void Awake()
{
// Add LevelPlay initialization as a component
gameObject.AddComponent<LevelPlayInitializer>();
// ... your other initialization code
}
}LevelPlayInitializer.csGameManagerLevelPlayInitializer.Awake()DontDestroyOnLoad(gameObject)LevelPlayInitializer.csGameManagerLevelPlayInitializer.csOnInitSuccessOnInitFailedInit()Awake()Start()DontDestroyOnLoad(gameObject);Awake()OnInitSuccessreferences/initialization-api.mdLevelPlayInitializer.csInit()OnInitSuccessOnInitFailedAwake()Start()Awake()DontDestroyOnLoad(gameObject);OnInitSuccessreferences/initialization-api.mdreferences/interstitial-api.mdreferences/interstitial-api.mdreferences/interstitial-api.mdreferences/interstitial-api.mdRewardedAdManager.csInterstitialAdManager.csBannerAdManager.csAdManager.csConfig.Builder().SetBidFloor(...)references/rewarded-api.mdreferences/interstitial-api.mdreferences/banner-api.mdRewardedAdManager.csInterstitialAdManager.csBannerAdManager.csAdManager.csConfig.Builder().SetBidFloor(...)references/rewarded-api.mdreferences/interstitial-api.mdreferences/banner-api.md.csRewardedAdManager.csInterstitialAdManager.csBannerAdManager.csAdManager.csLoadRewardedAd()LoadInterstitial()MonoBehaviourStart()OnDestroy()DontDestroyOnLoadDestroyAd()OnDestroy()Config.Builder().SetBidFloor(value).Build()new LevelPlayRewardedAd(adUnitId)var config = new LevelPlayRewardedAd.Config.Builder()
.SetBidFloor(0.80)
.Build();
rewardedAd = new LevelPlayRewardedAd(adUnitId, config);rewardedAd = new LevelPlayRewardedAd(adUnitId);references/ilrd-api.mdreferences/ilrd-api.mdLevelPlay.OnImpressionDataReadyLevelPlay.Init().csRewardedAdManager.csInterstitialAdManager.csBannerAdManager.csAdManager.csLoadRewardedAd()LoadInterstitial()MonoBehaviourStart()OnDestroy()DontDestroyOnLoadOnDestroy()DestroyAd()Config.Builder().SetBidFloor(value).Build()new LevelPlayRewardedAd(adUnitId)var config = new LevelPlayRewardedAd.Config.Builder()
.SetBidFloor(0.80)
.Build();
rewardedAd = new LevelPlayRewardedAd(adUnitId, config);rewardedAd = new LevelPlayRewardedAd(adUnitId);references/ilrd-api.mdreferences/ilrd-api.mdLevelPlay.Init()LevelPlay.OnImpressionDataReady// Initialize with your actual App Key (replace "abc123..." with yours)
// Mock ads work with any value, but use your real key to avoid forgetting to update it later
LevelPlay.Init("abc123youractualappkey");// In OnInitSuccess callback:
// Use your real ad unit ID from LevelPlay dashboard (replace "12345..." with yours)
// Mock ads work with any value, but use your real IDs to avoid forgetting to update them later
LevelPlayRewardedAd rewardedAd = new LevelPlayRewardedAd("12345youractualadunitid");
rewardedAd.OnAdLoaded += OnAdLoaded;
rewardedAd.OnAdRewarded += OnAdRewarded;
rewardedAd.LoadAd();OnAdLoadedOnAdDisplayedOnAdRewardedOnAdClosedOnAdLoadFailedOnAdDisplayFailedOnAdClickedOnAdExpandedOnAdCollapsedOnAdLeftApplicationOnAdInfoChangedLevelPlay.OnImpressionDataReadyLevelPlay.OnInitSuccessStart()LevelPlay.Init()OnInitSuccess// 使用你的实际App Key初始化(将"abc123..."替换为你的密钥)
// 模拟广告可与任何值配合使用,但使用真实密钥可避免稍后忘记更新
LevelPlay.Init("abc123youractualappkey");// 在OnInitSuccess回调中:
// 使用LevelPlay控制台中的真实广告单元ID(将"12345..."替换为你的ID)
// 模拟广告可与任何值配合使用,但使用真实ID可避免稍后忘记更新
LevelPlayRewardedAd rewardedAd = new LevelPlayRewardedAd("12345youractualadunitid");
rewardedAd.OnAdLoaded += OnAdLoaded;
rewardedAd.OnAdRewarded += OnAdRewarded;
rewardedAd.LoadAd();OnAdLoadedOnAdDisplayedOnAdRewardedOnAdClosedOnAdLoadFailedOnAdDisplayFailedOnAdClickedOnAdExpandedOnAdCollapsedOnAdLeftApplicationOnAdInfoChangedLevelPlay.OnImpressionDataReadyLevelPlay.OnInitSuccessLevelPlay.Init()Start()OnInitSuccessLevelPlayInitializer.csStart()LevelPlay.Init(appKey)LevelPlay.SetMetaData("is_test_suite", "enable");OnInitSuccessLevelPlay.LaunchTestSuite();LevelPlayInitializer.csusing UnityEngine;
using Unity.Services.LevelPlay;
public class LevelPlayInitializer : MonoBehaviour
{
[SerializeField] private string appKey;
void Awake()
{
DontDestroyOnLoad(gameObject);
}
void Start()
{
// Enable Test Suite — REMOVE before production release
LevelPlay.SetMetaData("is_test_suite", "enable");
LevelPlay.OnInitSuccess += OnInitSuccess;
LevelPlay.OnInitFailed += OnInitFailed;
LevelPlay.Init(appKey);
}
private void OnInitSuccess(LevelPlayConfiguration config)
{
Debug.Log("LevelPlay initialized successfully");
// Launch Test Suite — REMOVE before production release
LevelPlay.LaunchTestSuite();
}
private void OnInitFailed(LevelPlayInitError error)
{
Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
}
void OnDestroy()
{
LevelPlay.OnInitSuccess -= OnInitSuccess;
LevelPlay.OnInitFailed -= OnInitFailed;
}
}LevelPlay.SetMetaData("is_test_suite", "enable");LevelPlay.Init()LevelPlay.LaunchTestSuite();OnInitSuccessLevelPlayInitializer.csStart()LevelPlay.Init(appKey)LevelPlay.SetMetaData("is_test_suite", "enable");OnInitSuccessLevelPlay.LaunchTestSuite();LevelPlayInitializer.csusing UnityEngine;
using Unity.Services.LevelPlay;
public class LevelPlayInitializer : MonoBehaviour
{
[SerializeField] private string appKey;
void Awake()
{
DontDestroyOnLoad(gameObject);
}
void Start()
{
// Enable Test Suite — REMOVE before production release
LevelPlay.SetMetaData("is_test_suite", "enable");
LevelPlay.OnInitSuccess += OnInitSuccess;
LevelPlay.OnInitFailed += OnInitFailed;
LevelPlay.Init(appKey);
}
private void OnInitSuccess(LevelPlayConfiguration config)
{
Debug.Log("LevelPlay initialized successfully");
// Launch Test Suite — REMOVE before production release
LevelPlay.LaunchTestSuite();
}
private void OnInitFailed(LevelPlayInitError error)
{
Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
}
void OnDestroy()
{
LevelPlay.OnInitSuccess -= OnInitSuccess;
LevelPlay.OnInitFailed -= OnInitFailed;
}
}LevelPlay.SetMetaData("is_test_suite", "enable");LevelPlay.Init()LevelPlay.LaunchTestSuite();OnInitSuccessreferences/ios-setup.mdreferences/ios-setup.mdreferences/ios-setup.mdreferences/ios-setup.mdInterstitialAdManager.csRewardedAdManager.csreferences/interstitial-api.mdRewardedAdManager.csInterstitialAdManager.csreferences/interstitial-api.mdprivate void OnAdLoadFailed(LevelPlayAdError error)
{
Debug.LogWarning($"Ad failed to load: {error.ErrorMessage}");
// Retry loading after a delay
Invoke(nameof(LoadAd), 30f); // Retry in 30 seconds
// Provide fallback UX if ad was requested by user
// Don't leave users stuck waiting for an ad that won't load
}private void OnAdLoadFailed(LevelPlayAdError error)
{
Debug.LogWarning($"Ad failed to load: {error.ErrorMessage}");
// 延迟后重试加载
Invoke(nameof(LoadAd), 30f); // 30秒后重试
// 如果用户请求了广告,提供备用用户体验
// 不要让用户一直等待无法加载的广告
}void OnDestroy()
{
// Unsubscribe from all LevelPlay events
if (rewardedAd != null)
{
rewardedAd.OnAdLoaded -= OnAdLoaded;
rewardedAd.OnAdLoadFailed -= OnAdLoadFailed;
// ... unsubscribe from all other events
}
}void OnDestroy()
{
// 取消订阅所有LevelPlay事件
if (rewardedAd != null)
{
rewardedAd.OnAdLoaded -= OnAdLoaded;
rewardedAd.OnAdLoadFailed -= OnAdLoadFailed;
// ... 取消订阅所有其他事件
}
}The type or namespace name 'LevelPlay' could not be foundThe type or namespace name 'Unity.Services.LevelPlay' could not be foundusing Unity.Services.LevelPlay;The type or namespace name 'LevelPlay' could not be foundThe type or namespace name 'Unity.Services.LevelPlay' could not be foundusing Unity.Services.LevelPlay;Assets/Plugins/Android/Assets/Plugins/Android/LevelPlay.Init()OnInitSuccessOnInitSuccessLevelPlay.Init()OnInitSuccessOnInitSuccessInit()Init()references/ios-setup.mdreferences/ios-setup.mdreferences/rewarded-api.mdreferences/interstitial-api.mdreferences/banner-api.mdreferences/initialization-api.mdreferences/ios-setup.mdreferences/best-practices.mdreferences/privacy-settings.mdreferences/ilrd-api.mdreferences/rewarded-api.mdreferences/interstitial-api.mdreferences/banner-api.mdreferences/initialization-api.mdreferences/ios-setup.mdreferences/best-practices.mdreferences/privacy-settings.mdreferences/ilrd-api.md