مرکز راهنماراهنما در پنلبسته اتصال

Unity

بسته C# برای Android و iOS؛ بنر، ویدیو، تمام‌صفحه و جایزه سروری.

نسخه ۱ · اتصال مستقیم

سه قدم تا اولین تبلیغ Unity

  1. رسانه و جایگاه همان فرمت را ثبت و تأیید کنید.
  2. بسته همین پلتفرم را نصب کنید.
  3. شناسه UNT_ مثال را با شناسه جایگاه خود جایگزین کنید.
اپ شما به سرور نیاز ندارد.

نشانی HTTPS در مثال، سرور خود دیدنکس است. در حالت مستقیم، JWT، کلید خصوصی و ورود کاربر لازم نیست. Android، iOS، Unity و B4A شناسه بسته را از خود اپ می‌خوانند؛ Flutter نیز در initialize جدید، شناسه بسته را محلی می‌خواند؛ ورود دستی در روش سازگار قدیمی ممکن است. تغییر دامنه دیدنکس فقط به تغییر همین نشانی در تنظیم اپ نیاز دارد.

۱. نصب و تنظیم اولیه

ZIP را باز کنید؛ در Package Manager از Add package from disk، فایل package.json را انتخاب کنید. نمونه Samples~/DidnexQuickStart.cs را به Assets کپی و به یک GameObject اضافه کنید. در Scene یک Canvas همراه EventSystem بسازید و RectTransform ظرف تبلیغ را به bannerContainer بدهید. شناسه‌های placements را در Inspector تنظیم کنید.

Unity 2022.3 یا جدیدتر با UGUI؛ هدف Android/iOS. Editor برای تحویل تبلیغ زنده، WebGL و دسکتاپ پشتیبانی نمی‌شوند. ظرف درون صفحه حداقل ۱۰۰×۱۸۰ واحد منطقی داشته باشد.

using Didnex;
var ads=DidnexAds.CreateDirect("https://didnex.com");
var handle=await ads.ShowBannerAsync("UNT_BANNER",bannerContainer);
// Removal: handle?.Dispose();
// Owner shutdown: Destroy(ads.gameObject);

راه‌اندازی یک‌باره تبلیغ و پوش

نمونه کوتاه زیر فقط تنظیم اولیه است؛ callback و ظرف نمایش را در مثال کامل همین صفحه ببینید. init اجازه اعلان نمی‌گیرد و عضویت خودکار ندارد. یک کلاینت را برای عمر اپ نگه دارید و همان را برای تبلیغ و پوش استفاده کنید.

const string PlacementId = "PASTE_YOUR_PLACEMENT_ID_HERE";
var client = Didnex.DidnexAds.Initialize("https://didnex.com");
var ad = await client.ShowBannerAsync(PlacementId, bannerContainer);
var push = client.CreatePush(PlacementId);
// OnMessage returns true only after actual display. Permission is separate.

اندازه ثابت جایگاه

اندازه از slot جایگاه تعیین می‌شود؛ تصویر و ویدیو با contain داخل همان کادرند. ابعاد فایل یا آماده‌شدن ویدیو، اندازه بیرونی را عوض نمی‌کند. noFill و خطا کادر را جمع می‌کنند. در Unity و Godot مستطیل میزبان را مطابق پروفایل انتخاب کنید.

پروفایل دیدنکساندازه مرجعنوار ثابت زیر رسانه
بنر استاندارد ۳۲۰ × ۵۰320 × 50ندارد
بنر بزرگ ۳۲۰ × ۱۰۰320 × 100ندارد
بنر مستطیل ۳۰۰ × ۲۵۰300 × 250ندارد
بنر عریض ۷۲۸ × ۹۰728 × 90ندارد
بنر تطبیقی با نسبت ۳۲۰ × ۵۰320 × 50ندارد
همسان افقی ۱۶:۹ + نوار ثابت640 × 36084 پیکسل منطقی
همسان مربع + نوار ثابت600 × 60084 پیکسل منطقی
ویدیوی همسان ۱۶:۹ + نوار ثابت640 × 36084 پیکسل منطقی
ویدیوی درون محتوا ۱۶:۹640 × 360ندارد
کاروسل ۱۶:۹ با نوار ثابت640 × 36084 پیکسل منطقی
نظرسنجی در کادر ثابت320 × 30084 پیکسل منطقی
کارت صوتی ثابت320 × 96ندارد
تمام‌صفحه با حاشیه امن360 × 64084 پیکسل منطقی
تمام‌صفحه با حاشیه امن360 × 64084 پیکسل منطقی
تمام‌صفحه با حاشیه امن360 × 64084 پیکسل منطقی
تمام‌صفحه با حاشیه امن360 × 64084 پیکسل منطقی
تمام‌صفحه با حاشیه امن360 × 64084 پیکسل منطقی

این‌ها پروفایل محصول دیدنکس‌اند؛ گواهی استاندارد یا یک اندازه پیکسلی جهانی برای همه فرمت‌ها نیستند. حداقل وضوح در فرم کمپین کنترل می‌شود. برای فعال‌شدن renderer جدید در اپ نصب‌شده، یک بار SDK را به‌روزرسانی کنید.

فونت و ظاهر مشترک

ظاهر کارت در هر دو روش مستقیم و پراکسی از پاسخ همان تبلیغ خوانده می‌شود. مدیر در تنظیمات ← ظاهر تبلیغ و SDK، رنگ، زمینه، فونت، گردی کارت، جای نشان و پخش خودکار ویدیوی معمولی را تعیین می‌کند. ابتدا یک‌بار SDK و اپ را به‌روزرسانی کنید؛ سپس تغییرات پشتیبانی‌شده در درخواست بعدی تبلیغ اعمال می‌شوند. فونت Noto Sans Arabic فارسی و لوگو از سرور خود دیدنکس کش می‌شوند؛ خطای این دارایی‌های اختیاری باعث noFill یا خطای تبلیغ نمی‌شود. Unity برای UGUI یک فونت کوچک فارسی همراه و شکل‌دهی حروف در مرز نمایش دارد. سرور کد اجرایی جدید به اپ نمی‌فرستد.

ویدیوی معمولی هنگام دیده‌شدن خودکار و بی‌صداست؛ صوت و جایزه با انتخاب کاربر شروع می‌شوند. دامنه دیدنکس را در font-src سیاست CSP وب مجاز کنید.

۲. Manifest و مجوزهای لازم

قطعه زیر را با فایل موجود ادغام کنید. INTERNET باید در Manifest اصلی نسخه Release هم باشد. تبلیغ پایه به مجوز مکان، اعلان، حافظه یا شناسه تبلیغاتی نیاز ندارد.

<!-- Merge permissions into Assets/Plugins/Android/AndroidManifest.xml. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <application />
</manifest>

در iOS فایل PrivacyInfo.xcprivacy بسته را به منابع Target اضافه کنید؛ HTTPS به غیرفعال‌کردن ATS نیاز ندارد. UIBackgroundModes فقط برای پوش پس‌زمینه اختیاری است. در Unity دسترسی اینترنت Player Settings را روی Require قرار دهید.

بازکردن جایگاه و راهنمای قدم‌به‌قدم اتصال — در پنل، نمونه با شناسه و بستهٔ رسانهٔ شما ساخته می‌شود؛ تست تا دریافت گزارش همان جلسه ادامه دارد.

۳. مثال کامل هر فرمت

هر شناسه جایگاه فقط یک فرمت دارد؛ فرمت باید با نوع رسانه و سیاست‌های پنل سازگار باشد. مثال کامل همان فرمت را انتخاب کنید. تمام‌صفحه فقط در نقطه طبیعی تجربه کاربر نمایش داده شود. ویدیوی معمولی خودکار و بی‌صداست؛ صوت و جایزه با اقدام کاربر شروع می‌شوند.

بنر · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("banner") {unitId="UNT_BANNER"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("banner") {unitId="UNT_BANNER"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
بنر تطبیقی · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("adaptive_banner") {unitId="UNT_ADAPTIVE_BANNER"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("adaptive_banner") {unitId="UNT_ADAPTIVE_BANNER"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
همسان · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("native") {unitId="UNT_NATIVE"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("native") {unitId="UNT_NATIVE"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
ویدیوی همسان · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("native_video") {unitId="UNT_NATIVE_VIDEO"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("native_video") {unitId="UNT_NATIVE_VIDEO"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
ویدیوی درون محتوا · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("video") {unitId="UNT_VIDEO"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("video") {unitId="UNT_VIDEO"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
بینابینی · تمام‌صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("interstitial") {unitId="UNT_INTERSTITIAL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("interstitial") {unitId="UNT_INTERSTITIAL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
ویدیوی جایزه‌دار · جایزه‌دار
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("rewarded") {unitId="UNT_REWARDED"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("rewarded") {unitId="UNT_REWARDED"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
بینابینی جایزه‌دار · جایزه‌دار
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("rewarded_interstitial") {unitId="UNT_REWARDED_INTERSTITIAL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("rewarded_interstitial") {unitId="UNT_REWARDED_INTERSTITIAL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
آغاز اپ · تمام‌صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("app_open") {unitId="UNT_APP_OPEN"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("app_open") {unitId="UNT_APP_OPEN"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
بازی تعاملی · تمام‌صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("playable") {unitId="UNT_PLAYABLE"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("playable") {unitId="UNT_PLAYABLE"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
صوتی · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("audio") {unitId="UNT_AUDIO"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("audio") {unitId="UNT_AUDIO"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
کاروسلی · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("carousel") {unitId="UNT_CAROUSEL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("carousel") {unitId="UNT_CAROUSEL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
نظرسنجی · درون صفحه
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("poll") {unitId="UNT_POLL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}
روش سروری اختیاری همین فرمت

فقط برای اپ دارای سرور: نشانی پراکسی و تابع نشست فعلی اپ را تکمیل کنید. تابع خالی نمونه، نشست واقعی ایجاد نمی‌کند. کلید خصوصی روی سرور می‌ماند.

using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("poll") {unitId="UNT_POLL"}};
  string diagnosticToken = String.IsNullOrEmpty("") ? null : "";
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  // Replace with the current authenticated session from YOUR app.
  string CurrentAppSession(){return "";}
  void Awake(){try{ads=DidnexAds.Create("https://YOUR-BACKEND.example/ads",CurrentAppSession,adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId,diagnosticToken:diagnosticToken);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId,diagnosticToken:diagnosticToken);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer,diagnosticToken:diagnosticToken);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}

۴. مثال کامل با مدیریت خطا

این مثال عیناً از فایل sdk/unity/Samples~/DidnexQuickStart.cs داخل بسته ساخته می‌شود. نام package نمونه، شناسه‌های UNT_ و ظرف نمایش را با اپ خود هماهنگ کنید. برای بنر و تمام‌صفحه از نمونه جدا استفاده کنید.

نمایش مثال کامل Unity
using System;
using UnityEngine;
namespace Didnex.Samples {
 public sealed class DidnexQuickStart : MonoBehaviour {
  public RectTransform bannerContainer;
  public string adOrigin="https://didnex.com";
  [Serializable] public class Placement { public string format,unitId; public Placement(string f){format=f;unitId="UNT_"+f.ToUpperInvariant();} }
  public Placement[] placements={new Placement("banner"),new Placement("adaptive_banner"),new Placement("native"),new Placement("native_video"),new Placement("video"),new Placement("interstitial"),new Placement("rewarded"),new Placement("rewarded_interstitial"),new Placement("app_open"),new Placement("playable"),new Placement("audio"),new Placement("carousel"),new Placement("poll")};
  DidnexAds ads;DidnexAdHandle banner;bool busy;
  void Awake(){try{ads=DidnexAds.CreateDirect(adOrigin);ads.OnEvent+=(kind,code)=>{Debug.Log("Didnex "+kind);if(kind=="noFill"||kind=="error")SetSlotHeight(0);};}catch(Exception){Debug.LogWarning("Didnex configuration unavailable");}}
  // Connect UI buttons to ShowFormat, passing the format string from the list.
  public async void ShowFormat(string format){if(ads==null||busy)return;var p=Array.Find(placements,x=>x.format==format);if(p==null)return;busy=true;
   try{if(format=="rewarded"||format=="rewarded_interstitial"){var receipt=await ads.ShowRewardedAsync(p.unitId);if(receipt!=null){/* Already credited. Refresh the selected hosted wallet. */}}
    else if(format=="interstitial"||format=="app_open"||format=="playable"){await ads.ShowInterstitialAsync(p.unitId);}
    else{SetSlotHeight(300);banner?.Dispose();banner=await ads.ShowBannerAsync(p.unitId,bannerContainer);if(this==null)banner?.Dispose();}
   }catch(Exception){Debug.LogWarning("Didnex ad unavailable");}finally{busy=false;}
  }
  void SetSlotHeight(float height){if(bannerContainer==null)return;var layout=bannerContainer.GetComponent<UnityEngine.UI.LayoutElement>();if(layout!=null)layout.preferredHeight=height;else bannerContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,height);}
  void OnApplicationPause(bool paused){banner?.SetActive(!paused);}
  void OnDestroy(){banner?.Dispose();if(ads!=null)Destroy(ads.gameObject);}
 }
}

۵. نبود تبلیغ، قطعی شبکه و چرخه عمر

آغاز اپ را منتظر تبلیغ نگه ندارید. noFill وضعیت عادی است؛ فضای تبلیغ را مخفی کنید و اپ ادامه یابد. درخواست پشت سر هم و retry بی‌وقفه انجام ندهید. هنگام حذف صفحه، handle یا view را مطابق مثال ببندید. در تب پنهان یا پوشش سفارشی، active را false کنید. نمایش خودکار روی هر resume مناسب نیست.

۶. جایزه، کیف و پوش

جایزه فقط پس از انتخاب کاربر، تماشای کامل و رسید verified و applied سرور معتبر است. callback یعنی جایزه پیش‌تر در کیف نصب دیدنکس ثبت شده؛ دوباره به موجودی اضافه نکنید. برای مصرف، externalId را پیش از ارسال ذخیره و در retry ثابت نگه دارید. کیف نصب، حساب قابل بازیابی چنددستگاهی نیست.

Inbox بدون Firebase و در اپ فعال کار می‌کند. پوش پس‌زمینه به رضایت کاربر، مجوز سیستم‌عامل و اتصال FCM/APNs/Web Push نیاز دارد؛ فعال‌کردن تبلیغ به این تنظیم‌ها وابسته نیست. همه ۱۳ فرمت اتصال مستقیم دارند؛ React Native و Godot فعلاً مستقیم هستند و شش SDK اصلی پراکسی اختیاری هم دارند.

۷. آزمون و رفع خطا

diagnosticToken پنل، با فایل واقعی متناسب با فرمت (تصویر، ویدیو، صوت یا بازی) تست بدون هزینه و جایزه می‌دهد؛ تأیید تحویل مالی نیست. برای تبلیغ واقعی، کمپین سازگار با بودجه و رسانه فعال لازم است. در خطای package، پسوند flavor خروجی را با رسانه تطبیق دهید؛ در وب Origin دقیق و HTTPS را بررسی کنید. خطای سرویس را با موفقیت مالی یا جایزه محلی جایگزین نکنید.

آزمون‌های قرارداد سرور، وب و بسته‌بندی در مخزن اجرا می‌شوند. وضعیت کامپایل منطبق با هش منبع در SDK Lab و releases.json ثبت می‌شود؛ اجرای دستگاه فقط با رسید مستقل device_playback قابل تأیید است.

پیش از انتشار اپ، ساخت Release، قطع شبکه، DNS نامعتبر، پاسخ خراب، خروج صفحه وسط درخواست، پس‌زمینه و تکرار claim را روی دستگاه هدف بررسی کنید. مسیر ساخت تکرارپذیر و تست‌های هر SDK همراه سورس هستند.

قابلیت‌های SDK جدید و عیب‌یاب داخل اپ

نسخه نمایشی این انتشار ۱ است؛ شماره فنی و هش هر بسته در مرکز SDK درج شده است. هر ۱۱ فرمت در اتصال مستقیم و سرور اختیاری پشتیبانی می‌شوند؛ playable با helper بینابینی نمایش داده می‌شود و نیازمند SDK جدید است. در «لابراتوار تبلیغ»، بازی را بسازید و کمپین/جایگاه با فرمت playable انتخاب کنید. قالب‌های همان بازی در Flutter/Unity بومی رسم می‌شوند؛ وب و Kotlin/Swift/B4A از محیط HTML5 محدود استفاده می‌کنند.

برای عیب‌یاب، از پنل ناشر توکن تست جایگاه بگیرید و همان درخواست تست را اجرا کنید. در Flutter حالت debug، Android اپ debuggable، Swift ساخت DEBUG و Unity ساخت Development نیز مجازند. گزارش فقط محلی و محدود به ۸۰ رخداد، زمان، خطا، نوع رسانه و کیفیت است؛ کلید، JWT، URL امضاشده و شناسه مخاطب ثبت نمی‌شود. خروجی کپی را خودتان برای پشتیبانی می‌فرستید.

ads.ShowInspector(); // Development Build / test token

خروجی‌های ویدیوی تطبیقی به‌طور خودکار از mediaSources انتخاب می‌شوند. حالت کم‌مصرف/شبکه موبایل کیفیت پایین، Wi-Fi یا شبکه سریع کیفیت بالاتر و شبکه نامشخص کیفیت میانی می‌گیرد. اجازه ACCESS_NETWORK_STATE در Android برای تشخیص شبکه لازم است؛ در نبود دسترسی، انتخاب محافظه‌کارانه انجام می‌شود. رویداد بارگذاری، نمایش قابل مشاهده، پیشرفت ویدیو و تأیید جایزه همچنان از مسیر امضاشده می‌گذرند؛ عیب‌یاب درآمد ایجاد نمی‌کند.

ابزارهای ساخت موبایل و دستگاه واقعی در محیط انتشار این سورس در دسترس نبودند. آزمون قرارداد سرور، رمزنگاری، تولید رسانه و پنل انجام شده؛ پیش از انتشار اپ، ساخت SDK در Flutter/Xcode/Android Studio/Unity/B4A و آزمون دستگاه را انجام دهید. بسته‌ها روی pub.dev یا فروشگاه‌ها منتشر نشده‌اند.