t1k:unity:mobile:iap-tangle
| Field | Value |
|---|---|
| Module | mobile |
| Version | 3.65.6 |
| Effort | medium |
| Tools | — |
Keywords: AppleTangle, Google Play license key, GooglePlayTangle, iap obfuscation, IAP tangle, obfuscator, receipt validation, tangle generation, Unity IAP security
How to invoke
Section titled “How to invoke”/t1k:unity:mobile:iap-tangleUnity 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.
When to use
Section titled “When to use”- 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”.
Decision Tree
Section titled “Decision Tree”| Intent | Read |
|---|---|
| First run, Editor is open | Menu route |
| CI / no Editor open | Batchmode |
| Where the Google key comes from | Inputs |
| Why the built-in window needs login | references/iap-tangle-generation.md |
| Exact API, template, consts, asmdef | references/iap-tangle-generation.md |
| The editor script to ship/copy | assets/TangleGenerator.cs.txt |
Key facts
Section titled “Key facts”- 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/.
Inputs
Section titled “Inputs”| Platform | Input | Source |
|---|---|---|
| Apple | AppleIncRootCertificate.cer | bundled in package |
| AppleStoreKitTest | StoreKitTestCertificate.cer | bundled in package |
| GooglePlay | base64 license key | env UNITY_IAP_GOOGLE_PLAY_PUBLIC_KEY, else ProjectSettings/IapTangleKey.txt, else -iapGoogleKey <key> arg |
Menu route
Section titled “Menu route”With the Editor open, prefer a menu item (single-instance lock means batchmode cannot run
then — see rules/unity-forbidden-operations.md):
- Copy
assets/TangleGenerator.cs.txtinto anEditor/folder of the project and rename it toTangleGenerator.cs. - Invoke
Tools/IAP/Generate Tanglefrom the Editor menu (the Editor-owning agent can trigger it). - Confirm the three
.csfiles +Unity.Security.Tangle.asmdefunderAssets/Scripts/UnityPurchasing/generated/.
Batchmode (CI)
Section titled “Batchmode (CI)”The Editor holds a single-instance lock — close the Editor first, then:
source .claude/scripts/unity-batch-gate.sh # every headless launch goes through the machine-wide gateunity_batch_gate_run "$(unity_batch_gate_resolve <proj>)" -quit -batchmode -projectPath <proj> -executeMethod The1Studio.IAP.Editor.TangleGenerator.GenerateSet 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.
Verify
Section titled “Verify”- All four outputs exist under
Assets/Scripts/UnityPurchasing/generated/. - Each tangle file has
IsPopulated = trueand a non-emptydatabase64 string. - The project compiles (no
CS0246onObfuscator.DeObfuscate). - The build gate (
Packages/com.gdk.3rd/IAP/Editor/IAPTangleBuildGate.cs, Unity Purchasing path only, not armed underAIRWALLEX) fails Android builds whenGooglePlayTangle, and iOS builds whenAppleTangle, is missing, unpopulated or empty; bypass withT1K_SKIP_IAP_TANGLE_GATE.
Expected output shape and field meanings: references/iap-tangle-generation.md.
Hard rules
Section titled “Hard rules”- Output is random each run —
keyandorderare 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.templateexist incom.unity.purchasing5.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. ObfuscationGeneratorisinternal— onlyTangleObfuscator.Obfuscateispublic. 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.asmdeffor you (referencesUnity.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.
Executed by
Section titled “Executed by”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.
Related
Section titled “Related”t1k-unity-mobile-3rd-integrate— IAP as one integration class (defines, settings asset)references/iap-tangle-generation.md— full recipe, API surface, template, commit policyassets/TangleGenerator.cs.txt— the copyable editor script (template; copy + rename intoAssets/)