Unity (C#)
Experimental source reference. Zero third-party dependencies — UnityWebRequest + a tiny bundled JSON parser. Unity 2020.3+.
Experimental — verify runtime eligibility
Unity editor build, renderer integration and production eligibility remain unverified. Public package: Not verified. Source version: 1.0.0. See availability and capability evidence.| Package | co.theaimart.adx |
|---|---|
| Language | C# |
| Distribution | Source only; public installation not verified |
| Requirements | Unity 2020.3+. |
Install
Source setup — accessible SDK checkout required
bash
# Import the packages/unity source package from an accessible SDK checkout; public UPM access was not verified.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));
}));Unity editor build, renderer integration and production eligibility remain unverified.
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
| Member | Notes |
|---|---|
new Adx(apiKey) | Construct a client. |
adx.RequestAd(request, callback) | Coroutine — yield with StartCoroutine. |
adx.ReportViewable(impId) | Coroutine firing the viewability beacon. |
AdxBanner component | Attach 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.