Docs/SDKs

Unity (C#)

Zero third-party dependencies — UnityWebRequest + a tiny bundled JSON parser. Unity 2020.3+.

Packageco.theaimart.adx
LanguageC#
DistributionUPM (git URL)
RequirementsUnity 2020.3+.

Install

Packages/manifest.json

json
"co.theaimart.adx": "https://github.com/theaimartco/theaimart-adx-sdks.git?path=packages/unity"

Usage

Scripting

csharp
using Theaimart.Adx;

var adx = new Adx("pk_your_publisher_key");
StartCoroutine(adx.RequestAd(new AdRequest { SlotId = "8b1f-uuid" }, ad =>
{
    if (!ad.Filled) return;
    // render ad.Creative.AssetUrl (image) ...
    if (ad.IsTrackable)
        StartCoroutine(adx.ReportViewable(ad.ImpId));
}));

Production hardening

  • Fraud-safe User-Agent theaimart-adx-unity/<ver> (Android|iPhone…) — off the backend bot blocklist, with a device token.
  • SQL-filter-safe encoding of free-text params so real URLs never trip the WAF.
  • 4-way union parsing and fail-closed behavior (errors -> no-fill, never an exception).

These behaviors come directly from the wire contract — see User-Agent rules and WAF-safe encoding for why they matter. Not getting fills? See Troubleshooting.

API

MemberNotes
new Adx(apiKey)Construct a client.
adx.RequestAd(request, callback)Coroutine — yield with StartCoroutine.
adx.ReportViewable(impId)Coroutine firing the viewability beacon.
AdxBanner componentAttach to a RawImage inside a Canvas (with an EventSystem); set apiKey/slotId in the inspector for a drop-in banner.

The normalized Ad model

PascalCase mirror of the shared model: Filled, Kind, Source, ImpId, Creative, Auction, IsTrackable.

Build & test

text
Window > General > Test Runner > EditMode > Run All
# covers AdxEncoding and Ad parsing (NUnit). Rendering/networking requires Play mode.