Skip to content

t1k:unity:mobile:iap-tangle

FieldValue
Modulemobile
Version3.65.6
Effortmedium
Tools—

Keywords: AppleTangle, Google Play license key, GooglePlayTangle, iap obfuscation, IAP tangle, obfuscator, receipt validation, tangle generation, Unity IAP security

/t1k:unity:mobile:iap-tangle

Unity Mobile — IAP Tangle Generation (Offline)

Section titled “Unity Mobile — IAP Tangle Generation (Offline)”

Generate Assets/Scripts/UnityPurchasing/generated/{GooglePlay,Apple,AppleStoreKitTest}Tangle.cs without a Unity login, a project repo link, or the Services settings window.

  • Receipt-validation tangle files are missing, and the Services > In-App Purchasing > Receipt Validation Obfuscator... window is unavailable or demands a login.
  • You want scripted / CI / batchmode tangle generation instead of a manual menu click.
  • A request names “IAP obfuscator”, “tangle”, or “receipt-validation key”.
IntentRead
First run, Editor is openMenu route
CI / no Editor openBatchmode
Where the Google key comes fromInputs
Why the built-in window needs loginreferences/iap-tangle-generation.md
Exact API, template, consts, asmdefreferences/iap-tangle-generation.md
The editor script to ship/copyassets/TangleGenerator.cs.txt
  • Only Google needs an input. Apple and StoreKitTest certificates ship with the package (Packages/com.unity.purchasing/Editor/Apple/{AppleIncRootCertificate,StoreKitTestCertificate}.cer).
  • The Google Play license key is a PUBLIC key (Play Console > Monetize > Monetization setup > Licensing). It is not a secret — never source it from a human-typed form.
  • The generator is fully local — no network. Only the Services settings UI auto-fills the Google key from the Dashboard; the obfuscation itself never calls home.
  • Output path is fixed by the package: Assets/Scripts/UnityPurchasing/generated/.
PlatformInputSource
AppleAppleIncRootCertificate.cerbundled in package
AppleStoreKitTestStoreKitTestCertificate.cerbundled in package
GooglePlaybase64 license keyenv UNITY_IAP_GOOGLE_PLAY_PUBLIC_KEY, else ProjectSettings/IapTangleKey.txt, else -iapGoogleKey <key> arg

With the Editor open, prefer a menu item (single-instance lock means batchmode cannot run then — see rules/unity-forbidden-operations.md):

  1. Copy assets/TangleGenerator.cs.txt into an Editor/ folder of the project and rename it to TangleGenerator.cs.
  2. Invoke Tools/IAP/Generate Tangle from the Editor menu (the Editor-owning agent can trigger it).
  3. Confirm the three .cs files + Unity.Security.Tangle.asmdef under Assets/Scripts/UnityPurchasing/generated/.

The Editor holds a single-instance lock — close the Editor first, then:

Terminal window
source .claude/scripts/unity-batch-gate.sh # every headless launch goes through the machine-wide gate
unity_batch_gate_run "$(unity_batch_gate_resolve <proj>)" -quit -batchmode -projectPath <proj> -executeMethod The1Studio.IAP.Editor.TangleGenerator.Generate

Set UNITY_IAP_GOOGLE_PLAY_PUBLIC_KEY in the CI environment (never commit it — it is public but still project config). Append -iapGoogleKey <base64> to the command to pass it inline instead. See Inputs for the on-disk fallback.

  1. All four outputs exist under Assets/Scripts/UnityPurchasing/generated/.
  2. Each tangle file has IsPopulated = true and a non-empty data base64 string.
  3. The project compiles (no CS0246 on Obfuscator.DeObfuscate).
  4. The build gate (Packages/com.gdk.3rd/IAP/Editor/IAPTangleBuildGate.cs, Unity Purchasing path only, not armed under AIRWALLEX) fails Android builds when GooglePlayTangle, and iOS builds when AppleTangle, is missing, unpopulated or empty; bypass with T1K_SKIP_IAP_TANGLE_GATE.

Expected output shape and field meanings: references/iap-tangle-generation.md.

  • Output is random each run — key and order are re-rolled, so committing the files produces noisy diffs. Decide the commit policy once (see the reference’s commit-policy note) and stick to it.
  • Verify the package version first. TangleObfuscator + the .cs.template exist in com.unity.purchasing 5.3.1 and 5.4.1 (identical obfuscator source, verified); older 4.x layouts differ — re-check before relying on the paths in this skill.
  • ObfuscationGenerator is internal — only TangleObfuscator.Obfuscate is public. The shipped script calls the public static directly and fills its own embedded template.
  • The generated folder needs its asmdef or the project will not compile — the script writes Unity.Security.Tangle.asmdef for you (references Unity.Services.Core, Unity.Purchasing.Security, Unity.Purchasing.SecurityCore, Unity.Purchasing.SecurityStub).
  • Do not hand-edit generated tangle files — the header says so, and the next run overwrites them.
  • Full gotcha list (menu availability, ENABLE_EDITOR_GAME_SERVICES, Editor mutex): references/iap-tangle-generation.md.

t1k-unity-base-developer — it owns the Unity Editor surface this skill needs; run inline only when the Editor is already open and a menu invoke is the whole task.

  • t1k-unity-mobile-3rd-integrate — IAP as one integration class (defines, settings asset)
  • references/iap-tangle-generation.md — full recipe, API surface, template, commit policy
  • assets/TangleGenerator.cs.txt — the copyable editor script (template; copy + rename into Assets/)