nccgs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/.claude/agents/nccgs-accessibility-specialist.md +26 -0
  2. package/.claude/agents/nccgs-adversarial-reviewer.md +26 -0
  3. package/.claude/agents/nccgs-ai-programmer.md +26 -0
  4. package/.claude/agents/nccgs-analytics-engineer.md +26 -0
  5. package/.claude/agents/nccgs-art-direction-lead.md +26 -0
  6. package/.claude/agents/nccgs-audio-direction-lead.md +26 -0
  7. package/.claude/agents/nccgs-creative-director.md +26 -0
  8. package/.claude/agents/nccgs-documentation-manager.md +26 -0
  9. package/.claude/agents/nccgs-economy-designer.md +26 -0
  10. package/.claude/agents/nccgs-engine-programmer.md +26 -0
  11. package/.claude/agents/nccgs-game-design-lead.md +26 -0
  12. package/.claude/agents/nccgs-game-designer.md +26 -0
  13. package/.claude/agents/nccgs-gameplay-programmer.md +26 -0
  14. package/.claude/agents/nccgs-level-designer.md +26 -0
  15. package/.claude/agents/nccgs-live-ops-designer.md +26 -0
  16. package/.claude/agents/nccgs-localization-lead.md +26 -0
  17. package/.claude/agents/nccgs-narrative-lead.md +26 -0
  18. package/.claude/agents/nccgs-network-programmer.md +26 -0
  19. package/.claude/agents/nccgs-performance-analyst.md +26 -0
  20. package/.claude/agents/nccgs-producer.md +26 -0
  21. package/.claude/agents/nccgs-production-coordinator.md +23 -0
  22. package/.claude/agents/nccgs-programming-lead.md +26 -0
  23. package/.claude/agents/nccgs-prototyper.md +26 -0
  24. package/.claude/agents/nccgs-qa-engineer.md +26 -0
  25. package/.claude/agents/nccgs-qa-lead.md +26 -0
  26. package/.claude/agents/nccgs-release-engineer.md +26 -0
  27. package/.claude/agents/nccgs-release-lead.md +26 -0
  28. package/.claude/agents/nccgs-security-engineer.md +26 -0
  29. package/.claude/agents/nccgs-sound-designer.md +26 -0
  30. package/.claude/agents/nccgs-systems-designer.md +26 -0
  31. package/.claude/agents/nccgs-technical-architect.md +26 -0
  32. package/.claude/agents/nccgs-technical-artist.md +26 -0
  33. package/.claude/agents/nccgs-technical-director.md +26 -0
  34. package/.claude/agents/nccgs-tools-programmer.md +26 -0
  35. package/.claude/agents/nccgs-ui-programmer.md +26 -0
  36. package/.claude/agents/nccgs-unity-build-specialist.md +26 -0
  37. package/.claude/agents/nccgs-unity-content-specialist.md +26 -0
  38. package/.claude/agents/nccgs-unity-implementer.md +26 -0
  39. package/.claude/agents/nccgs-unity-rendering-specialist.md +26 -0
  40. package/.claude/agents/nccgs-unity-systems-specialist.md +26 -0
  41. package/.claude/agents/nccgs-unity-ui-specialist.md +26 -0
  42. package/.claude/agents/nccgs-ux-designer.md +26 -0
  43. package/.claude/agents/nccgs-verification-engineer.md +26 -0
  44. package/.claude/agents/nccgs-world-builder.md +26 -0
  45. package/.claude/agents/nccgs-writer.md +26 -0
  46. package/.claude/nccgs/THIRD_PARTY_NOTICES.md +13 -0
  47. package/.claude/nccgs/VERSION +1 -0
  48. package/.claude/nccgs/constitution.md +131 -0
  49. package/.claude/nccgs/hooks/agent-audit.mjs +10 -0
  50. package/.claude/nccgs/hooks/common.mjs +41 -0
  51. package/.claude/nccgs/hooks/post-compact.mjs +1 -0
  52. package/.claude/nccgs/hooks/pre-compact.mjs +8 -0
  53. package/.claude/nccgs/hooks/protect-git.mjs +22 -0
  54. package/.claude/nccgs/hooks/protect-write.mjs +17 -0
  55. package/.claude/nccgs/hooks/session-start.mjs +15 -0
  56. package/.claude/nccgs/hooks/session-stop.mjs +7 -0
  57. package/.claude/nccgs/protocols/agent-contract.md +34 -0
  58. package/.claude/nccgs/protocols/context-packets.md +13 -0
  59. package/.claude/nccgs/protocols/evidence.md +15 -0
  60. package/.claude/nccgs/protocols/model-routing.md +22 -0
  61. package/.claude/nccgs/protocols/orchestration.md +26 -0
  62. package/.claude/nccgs/protocols/unity-boundary.md +11 -0
  63. package/.claude/nccgs/settings.fragment.json +77 -0
  64. package/.claude/nccgs/studio.json +347 -0
  65. package/.claude/nccgs/tools/configure-models.mjs +39 -0
  66. package/.claude/nccgs/unity-skills-manifest.json +727 -0
  67. package/.claude/nccgs/workflow-catalog.json +317 -0
  68. package/.claude/rules/nccgs-canonical-docs.md +19 -0
  69. package/.claude/rules/nccgs-editor-tools.md +12 -0
  70. package/.claude/rules/nccgs-localization.md +12 -0
  71. package/.claude/rules/nccgs-networking.md +13 -0
  72. package/.claude/rules/nccgs-performance.md +14 -0
  73. package/.claude/rules/nccgs-rendering.md +16 -0
  74. package/.claude/rules/nccgs-security.md +13 -0
  75. package/.claude/rules/nccgs-tests.md +18 -0
  76. package/.claude/rules/nccgs-ui.md +14 -0
  77. package/.claude/rules/nccgs-unity-assets.md +21 -0
  78. package/.claude/rules/nccgs-unity-code.md +22 -0
  79. package/.claude/skills/accessibility-review/SKILL.md +14 -0
  80. package/.claude/skills/architecture-decision/SKILL.md +14 -0
  81. package/.claude/skills/asset-audit/SKILL.md +14 -0
  82. package/.claude/skills/audit/SKILL.md +16 -0
  83. package/.claude/skills/audit/references/dimensions.md +46 -0
  84. package/.claude/skills/balance-review/SKILL.md +14 -0
  85. package/.claude/skills/bug-triage/SKILL.md +14 -0
  86. package/.claude/skills/build-live-game/SKILL.md +317 -0
  87. package/.claude/skills/build-live-game/references/achievements.md +779 -0
  88. package/.claude/skills/build-live-game/references/apis.md +280 -0
  89. package/.claude/skills/build-live-game/references/authentication.md +437 -0
  90. package/.claude/skills/build-live-game/references/battlepass.md +860 -0
  91. package/.claude/skills/build-live-game/references/cloud-code.md +563 -0
  92. package/.claude/skills/build-live-game/references/cloud-save.md +474 -0
  93. package/.claude/skills/build-live-game/references/deployment.md +216 -0
  94. package/.claude/skills/build-live-game/references/player-account.md +813 -0
  95. package/.claude/skills/build-live-game/references/remote-config.md +96 -0
  96. package/.claude/skills/build-live-game/references/tooling.md +431 -0
  97. package/.claude/skills/closure/SKILL.md +14 -0
  98. package/.claude/skills/code-review/SKILL.md +14 -0
  99. package/.claude/skills/compatibility-review/SKILL.md +14 -0
  100. package/.claude/skills/context-pack/SKILL.md +14 -0
  101. package/.claude/skills/dependency-review/SKILL.md +14 -0
  102. package/.claude/skills/design/SKILL.md +20 -0
  103. package/.claude/skills/design-review/SKILL.md +14 -0
  104. package/.claude/skills/evidence-review/SKILL.md +14 -0
  105. package/.claude/skills/hotfix/SKILL.md +14 -0
  106. package/.claude/skills/implement-in-app-purchases/README.md +233 -0
  107. package/.claude/skills/implement-in-app-purchases/SKILL.md +158 -0
  108. package/.claude/skills/implement-in-app-purchases/references/api-notes.md +562 -0
  109. package/.claude/skills/implement-in-app-purchases/references/codeless-catalog.md +331 -0
  110. package/.claude/skills/implement-in-app-purchases/references/convert-adapty.md +268 -0
  111. package/.claude/skills/implement-in-app-purchases/references/convert-essentialkit.md +239 -0
  112. package/.claude/skills/implement-in-app-purchases/references/convert-revenuecat.md +275 -0
  113. package/.claude/skills/implement-in-app-purchases/references/convert-unipay.md +145 -0
  114. package/.claude/skills/implement-in-app-purchases/references/migration-v4-to-v5.md +204 -0
  115. package/.claude/skills/implement-in-app-purchases/references/path-add-iap-to-new-project.md +198 -0
  116. package/.claude/skills/implement-in-app-purchases/references/path-convert-native-google-billing.md +356 -0
  117. package/.claude/skills/implement-in-app-purchases/references/path-convert-native-storekit.md +446 -0
  118. package/.claude/skills/implement-in-app-purchases/references/path-implement-iap-d2c.md +680 -0
  119. package/.claude/skills/implement-in-app-purchases/references/platform-notes.md +204 -0
  120. package/.claude/skills/implement-in-app-purchases/references/pre-check.md +205 -0
  121. package/.claude/skills/incident-recovery/SKILL.md +14 -0
  122. package/.claude/skills/initialize-ai-navigation/SKILL.md +95 -0
  123. package/.claude/skills/initialize-ai-navigation/references/navigation-system.md +794 -0
  124. package/.claude/skills/levelplay-unity-integration/CHANGELOG.md +57 -0
  125. package/.claude/skills/levelplay-unity-integration/README.md +74 -0
  126. package/.claude/skills/levelplay-unity-integration/SKILL.md +1126 -0
  127. package/.claude/skills/levelplay-unity-integration/references/banner-api.md +920 -0
  128. package/.claude/skills/levelplay-unity-integration/references/best-practices.md +536 -0
  129. package/.claude/skills/levelplay-unity-integration/references/ilrd-api.md +337 -0
  130. package/.claude/skills/levelplay-unity-integration/references/initialization-api.md +630 -0
  131. package/.claude/skills/levelplay-unity-integration/references/interstitial-api.md +899 -0
  132. package/.claude/skills/levelplay-unity-integration/references/ios-setup.md +491 -0
  133. package/.claude/skills/levelplay-unity-integration/references/migration-sdk-9.md +666 -0
  134. package/.claude/skills/levelplay-unity-integration/references/privacy-settings.md +608 -0
  135. package/.claude/skills/levelplay-unity-integration/references/rewarded-api.md +902 -0
  136. package/.claude/skills/localization/SKILL.md +135 -0
  137. package/.claude/skills/localization/references/api-notes.md +76 -0
  138. package/.claude/skills/localization/resources/L10nBatchProcessor.cs +69 -0
  139. package/.claude/skills/localization/resources/LocalizedFontAsset.cs +18 -0
  140. package/.claude/skills/localize-game/SKILL.md +14 -0
  141. package/.claude/skills/migrate-project/SKILL.md +21 -0
  142. package/.claude/skills/migrate-project/references/procedure.md +63 -0
  143. package/.claude/skills/milestone-review/SKILL.md +14 -0
  144. package/.claude/skills/new-unity-project/SKILL.md +179 -0
  145. package/.claude/skills/optimize-audio/SKILL.md +199 -0
  146. package/.claude/skills/optimize-audio/resources/audio-import-api.md +146 -0
  147. package/.claude/skills/optimize-audio/resources/platform-settings.md +48 -0
  148. package/.claude/skills/optimize-text-mesh-pro/SKILL.md +182 -0
  149. package/.claude/skills/optimize-web/SKILL.md +393 -0
  150. package/.claude/skills/optimize-web/resources/WebOptimizer.cs +21 -0
  151. package/.claude/skills/optimize-web/resources/toktx-examples.sh +11 -0
  152. package/.claude/skills/performance-audit/SKILL.md +14 -0
  153. package/.claude/skills/physics-3d-collision/SKILL.md +442 -0
  154. package/.claude/skills/physics-3d-collision/references/troubleshooting.md +41 -0
  155. package/.claude/skills/physics-3d-collision/resources/CollisionDebugger.cs +33 -0
  156. package/.claude/skills/plan-feature/SKILL.md +14 -0
  157. package/.claude/skills/playtest/SKILL.md +14 -0
  158. package/.claude/skills/project-stage/SKILL.md +14 -0
  159. package/.claude/skills/prototype-feature/SKILL.md +14 -0
  160. package/.claude/skills/qa-plan/SKILL.md +14 -0
  161. package/.claude/skills/release/SKILL.md +18 -0
  162. package/.claude/skills/release-readiness/SKILL.md +14 -0
  163. package/.claude/skills/retrospective/SKILL.md +14 -0
  164. package/.claude/skills/review/SKILL.md +16 -0
  165. package/.claude/skills/security-audit/SKILL.md +14 -0
  166. package/.claude/skills/setup-multiplayer-services/SKILL.md +39 -0
  167. package/.claude/skills/setup-multiplayer-services/references/dgs-entrypoint.md +79 -0
  168. package/.claude/skills/setup-multiplayer-services/references/entrypoints.md +213 -0
  169. package/.claude/skills/setup-multiplayer-services/references/examples.md +33 -0
  170. package/.claude/skills/setup-multiplayer-services/references/implementation-fit.md +30 -0
  171. package/.claude/skills/setup-multiplayer-services/references/underlying-services.md +11 -0
  172. package/.claude/skills/setup-multiplayer-services/references/workflows-prerequisites.md +17 -0
  173. package/.claude/skills/setup-vivox-voice-chat/SKILL.md +118 -0
  174. package/.claude/skills/setup-vivox-voice-chat/evals/.env.example +6 -0
  175. package/.claude/skills/setup-vivox-voice-chat/evals/README.md +101 -0
  176. package/.claude/skills/setup-vivox-voice-chat/evals/promptfooconfig.yaml +32 -0
  177. package/.claude/skills/setup-vivox-voice-chat/evals/tests/init-and-login.yaml +76 -0
  178. package/.claude/skills/setup-vivox-voice-chat/evals/tests/text-chat.yaml +65 -0
  179. package/.claude/skills/setup-vivox-voice-chat/evals/tests/voice-channels.yaml +74 -0
  180. package/.claude/skills/setup-vivox-voice-chat/references/events-and-participants.md +79 -0
  181. package/.claude/skills/setup-vivox-voice-chat/references/init-and-login.md +92 -0
  182. package/.claude/skills/setup-vivox-voice-chat/references/text-chat.md +93 -0
  183. package/.claude/skills/setup-vivox-voice-chat/references/troubleshooting.md +47 -0
  184. package/.claude/skills/setup-vivox-voice-chat/references/voice-channels.md +90 -0
  185. package/.claude/skills/shader-graph-create-custom-node/SKILL.md +25 -0
  186. package/.claude/skills/shader-graph-create-custom-node/resources/all_hints.hlsl +182 -0
  187. package/.claude/skills/sprint-plan/SKILL.md +14 -0
  188. package/.claude/skills/sprite-editor/SKILL.md +66 -0
  189. package/.claude/skills/sprite-editor/references/api_reference.md +151 -0
  190. package/.claude/skills/sprite-editor/references/background.md +112 -0
  191. package/.claude/skills/sprite-editor/references/templates.md +72 -0
  192. package/.claude/skills/sprite-editor/scripts/AutomaticSliceTexture.cs +40 -0
  193. package/.claude/skills/sprite-editor/scripts/GenerateNewSpriteRects.cs +200 -0
  194. package/.claude/skills/sprite-editor/scripts/GetTextureSourceImageSize.cs +32 -0
  195. package/.claude/skills/sprite-editor/scripts/GetTextureToSlice.cs +55 -0
  196. package/.claude/skills/sprite-editor/scripts/GridSliceTexture.cs +40 -0
  197. package/.claude/skills/sprite-editor/scripts/IsometricSliceTexture.cs +141 -0
  198. package/.claude/skills/sprite-editor/scripts/README.md +134 -0
  199. package/.claude/skills/sprite-editor/scripts/SetPivotExample.cs +58 -0
  200. package/.claude/skills/sprite-editor/scripts/SpriteToPng.cs +88 -0
  201. package/.claude/skills/status/SKILL.md +16 -0
  202. package/.claude/skills/story-readiness/SKILL.md +14 -0
  203. package/.claude/skills/test/SKILL.md +16 -0
  204. package/.claude/skills/ui/SKILL.md +142 -0
  205. package/.claude/skills/ui-imgui/SKILL.md +186 -0
  206. package/.claude/skills/ui-imgui/references/gui-elements.md +156 -0
  207. package/.claude/skills/ui-imgui/references/templates.md +141 -0
  208. package/.claude/skills/ui-review/SKILL.md +14 -0
  209. package/.claude/skills/ui-ugui/SKILL.md +282 -0
  210. package/.claude/skills/ui-ugui/references/scrollview-setup.md +29 -0
  211. package/.claude/skills/ui-uitk/SKILL.md +235 -0
  212. package/.claude/skills/ui-uitk/references/common-issues.md +74 -0
  213. package/.claude/skills/ui-uitk/references/custom-elements.md +241 -0
  214. package/.claude/skills/ui-uitk/references/painter2d.md +282 -0
  215. package/.claude/skills/ui-uitk/references/pointermanipulator-guide.md +94 -0
  216. package/.claude/skills/ui-uitk/references/svg-icons.md +136 -0
  217. package/.claude/skills/ui-uitk/references/ui-runtime-binding.md +234 -0
  218. package/.claude/skills/ui-uitk/references/uss-guide.md +138 -0
  219. package/.claude/skills/unity-cli/CHANGELOG.md +233 -0
  220. package/.claude/skills/unity-cli/SECURITY.md +22 -0
  221. package/.claude/skills/unity-cli/SKILL.md +414 -0
  222. package/.claude/skills/unity-cli/references/auth-license-cloud.md +146 -0
  223. package/.claude/skills/unity-cli/references/build-run-test.md +349 -0
  224. package/.claude/skills/unity-cli/references/collaboration.md +472 -0
  225. package/.claude/skills/unity-cli/references/config-hub.md +103 -0
  226. package/.claude/skills/unity-cli/references/diagnostics-maintenance.md +326 -0
  227. package/.claude/skills/unity-cli/references/editors-install.md +327 -0
  228. package/.claude/skills/unity-cli/references/integration-advanced.md +472 -0
  229. package/.claude/skills/unity-cli/references/projects-templates.md +574 -0
  230. package/.claude/skills/unity-package-management/SKILL.md +304 -0
  231. package/.claude/skills/unity-package-management/references/select-packages.md +108 -0
  232. package/.claude/skills/urp-postprocessing/SKILL.md +188 -0
  233. package/.claude/skills/urp-postprocessing/references/code-templates.md +119 -0
  234. package/.claude/skills/urp-postprocessing/references/effect-reference.md +86 -0
  235. package/.claude/skills/validate-urp-render-graph-renderer-feature/SKILL.md +269 -0
  236. package/.claude/skills/work/SKILL.md +36 -0
  237. package/.claude/skills/work/references/classification.md +41 -0
  238. package/.claude/skills/work/references/closure.md +50 -0
  239. package/.claude/skills/work/references/feature-contracts.md +32 -0
  240. package/.claude/skills/work/references/verification.md +26 -0
  241. package/CLAUDE.md +6 -0
  242. package/LICENSE +21 -0
  243. package/README.md +162 -0
  244. package/THIRD_PARTY_NOTICES.md +23 -0
  245. package/UPGRADING.md +32 -0
  246. package/VERSION +1 -0
  247. package/docs/ARCHITECTURE.md +73 -0
  248. package/docs/HUONG-DAN-MIGRATE-VA-SU-DUNG.md +324 -0
  249. package/docs/MIGRATION-MATRIX.md +23 -0
  250. package/docs/PROJECT-POLICY.md +67 -0
  251. package/docs/WORKFLOWS.md +61 -0
  252. package/package-assets/setup-vivox-voice-chat-evals.gitignore +7 -0
  253. package/package.json +41 -0
  254. package/scaffold/.nccgs/bugs/.gitkeep +1 -0
  255. package/scaffold/.nccgs/closures/.gitkeep +1 -0
  256. package/scaffold/.nccgs/context/.gitkeep +1 -0
  257. package/scaffold/.nccgs/decisions/.gitkeep +1 -0
  258. package/scaffold/.nccgs/evidence/.gitkeep +1 -0
  259. package/scaffold/.nccgs/features/.gitkeep +1 -0
  260. package/scaffold/.nccgs/migrations/.gitkeep +1 -0
  261. package/scaffold/.nccgs/playtests/.gitkeep +1 -0
  262. package/scaffold/.nccgs/project.yaml +103 -0
  263. package/scaffold/.nccgs/requirements.yaml +10 -0
  264. package/scaffold/.nccgs/reviews/.gitkeep +1 -0
  265. package/scaffold/.nccgs/state.md +40 -0
  266. package/scaffold/.nccgs/templates/agent-handoff.md +25 -0
  267. package/scaffold/.nccgs/templates/architecture-decision.md +27 -0
  268. package/scaffold/.nccgs/templates/closure-record.md +51 -0
  269. package/scaffold/.nccgs/templates/context-packet.yaml +17 -0
  270. package/scaffold/.nccgs/templates/evidence-record.md +23 -0
  271. package/scaffold/.nccgs/templates/feature-contract.md +35 -0
  272. package/scaffold/.nccgs/templates/migration-plan.md +40 -0
  273. package/scaffold/.nccgs/templates/waiver.md +11 -0
  274. package/scripts/cli.mjs +56 -0
  275. package/scripts/install.mjs +267 -0
  276. package/scripts/sync-unity-skills.mjs +126 -0
  277. package/scripts/validate.mjs +205 -0
  278. package/tests/framework.test.mjs +121 -0
@@ -0,0 +1,630 @@
1
+ # LevelPlay SDK Initialization API
2
+
3
+ ## Contents
4
+ - [Overview](#overview)
5
+ - [Basic Initialization](#basic-initialization)
6
+ - [Advanced Initialization](#advanced-initialization)
7
+ - [API Reference](#api-reference)
8
+ - [Initialization Timing](#initialization-timing)
9
+ - [Best Practices](#best-practices)
10
+ - [Testing](#testing)
11
+ - [Migration from IronSource.* APIs](#migration-from-ironsource-apis)
12
+ - [Error Code Reference](#error-code-reference)
13
+
14
+ ## Overview
15
+
16
+ Proper SDK initialization is critical for LevelPlay to function correctly. This reference covers basic initialization, advanced options, and best practices.
17
+
18
+ ## Basic Initialization
19
+
20
+ ### Minimum Required Setup
21
+
22
+ ```csharp
23
+ using UnityEngine;
24
+ using Unity.Services.LevelPlay;
25
+
26
+ public class LevelPlayInitializer : MonoBehaviour
27
+ {
28
+ [SerializeField] private string appKey = "YOUR_APP_KEY";
29
+
30
+ void Start()
31
+ {
32
+ // Register initialization callbacks
33
+ LevelPlay.OnInitSuccess += OnInitSuccess;
34
+ LevelPlay.OnInitFailed += OnInitFailed;
35
+
36
+ // Initialize SDK
37
+ LevelPlay.Init(appKey);
38
+ }
39
+
40
+ void OnDestroy()
41
+ {
42
+ // Unregister callbacks
43
+ LevelPlay.OnInitSuccess -= OnInitSuccess;
44
+ LevelPlay.OnInitFailed -= OnInitFailed;
45
+ }
46
+
47
+ private void OnInitSuccess(LevelPlayConfiguration config)
48
+ {
49
+ Debug.Log("LevelPlay SDK initialized successfully");
50
+ // SDK is ready - you can now create ad objects
51
+ }
52
+
53
+ private void OnInitFailed(LevelPlayInitError error)
54
+ {
55
+ Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
56
+ }
57
+ }
58
+ ```
59
+
60
+ **Key points:**
61
+ - Register `OnInitSuccess` and `OnInitFailed` callbacks before calling `Init()`
62
+ - The `appKey` is obtained from your LevelPlay dashboard
63
+ - Call `Init()` as early as possible (ideally in the first scene)
64
+ - Only create ad objects after `OnInitSuccess` fires
65
+
66
+ ## Advanced Initialization
67
+
68
+ ### With User ID
69
+
70
+ ```csharp
71
+ using UnityEngine;
72
+ using Unity.Services.LevelPlay;
73
+
74
+ public class AdvancedInitializer : MonoBehaviour
75
+ {
76
+ [SerializeField] private string appKey = "YOUR_APP_KEY";
77
+
78
+ void Start()
79
+ {
80
+ // Register callbacks
81
+ LevelPlay.OnInitSuccess += OnInitSuccess;
82
+ LevelPlay.OnInitFailed += OnInitFailed;
83
+
84
+ // Initialize SDK with optional user ID
85
+ string userId = "user_12345"; // Your internal user ID
86
+ LevelPlay.Init(appKey, userId);
87
+ }
88
+
89
+ void OnDestroy()
90
+ {
91
+ LevelPlay.OnInitSuccess -= OnInitSuccess;
92
+ LevelPlay.OnInitFailed -= OnInitFailed;
93
+ }
94
+
95
+ private void OnInitSuccess(LevelPlayConfiguration config)
96
+ {
97
+ Debug.Log("LevelPlay initialized successfully");
98
+ }
99
+
100
+ private void OnInitFailed(LevelPlayInitError error)
101
+ {
102
+ Debug.LogError($"Init failed: {error.ErrorMessage}");
103
+ }
104
+ }
105
+ ```
106
+
107
+ **When to use:** When you need to track users across sessions or implement server-side verification for rewards.
108
+
109
+ ### Complete Production-Ready Example
110
+
111
+ ```csharp
112
+ using UnityEngine;
113
+ using Unity.Services.LevelPlay;
114
+
115
+ public class ProductionLevelPlayInitializer : MonoBehaviour
116
+ {
117
+ [Header("Configuration")]
118
+ [SerializeField] private string appKey = "YOUR_APP_KEY";
119
+
120
+ void Awake()
121
+ {
122
+ // Ensure this object persists across scenes
123
+ DontDestroyOnLoad(gameObject);
124
+
125
+ // Initialize as early as possible
126
+ InitializeLevelPlay();
127
+ }
128
+
129
+ private void InitializeLevelPlay()
130
+ {
131
+ // Register initialization callbacks
132
+ LevelPlay.OnInitSuccess += OnInitSuccess;
133
+ LevelPlay.OnInitFailed += OnInitFailed;
134
+
135
+ // Initialize SDK with optional user ID
136
+ if (HasUserId())
137
+ {
138
+ string userId = GetUserId();
139
+ LevelPlay.Init(appKey, userId);
140
+ Debug.Log($"LevelPlay SDK initialization started with user ID: {userId}");
141
+ }
142
+ else
143
+ {
144
+ LevelPlay.Init(appKey);
145
+ Debug.Log("LevelPlay SDK initialization started");
146
+ }
147
+ }
148
+
149
+ void OnDestroy()
150
+ {
151
+ // Unregister callbacks
152
+ LevelPlay.OnInitSuccess -= OnInitSuccess;
153
+ LevelPlay.OnInitFailed -= OnInitFailed;
154
+ }
155
+
156
+ private void OnInitSuccess(LevelPlayConfiguration config)
157
+ {
158
+ Debug.Log("LevelPlay SDK initialization completed");
159
+
160
+ // SDK is ready - create ad objects here
161
+ CreateAdObjects();
162
+ }
163
+
164
+ private void OnInitFailed(LevelPlayInitError error)
165
+ {
166
+ Debug.LogError($"LevelPlay initialization failed: {error.ErrorMessage}");
167
+
168
+ // Optionally retry initialization after delay
169
+ Invoke(nameof(RetryInitialization), 5f);
170
+ }
171
+
172
+ private void RetryInitialization()
173
+ {
174
+ Debug.Log("Retrying LevelPlay initialization...");
175
+ LevelPlay.Init(appKey);
176
+ }
177
+
178
+ private bool HasUserId()
179
+ {
180
+ // Check if user is logged in and has an ID
181
+ return !string.IsNullOrEmpty(PlayerPrefs.GetString("UserID", ""));
182
+ }
183
+
184
+ private string GetUserId()
185
+ {
186
+ // Get your internal user ID
187
+ return PlayerPrefs.GetString("UserID", "");
188
+ }
189
+
190
+ private void CreateAdObjects()
191
+ {
192
+ // Create your ad objects here after init succeeds
193
+ // Example:
194
+ // rewardedAd = new LevelPlayRewardedAd("rewarded_ad_unit_id");
195
+ // interstitialAd = new LevelPlayInterstitialAd("interstitial_ad_unit_id");
196
+ Debug.Log("Creating ad objects...");
197
+ }
198
+ }
199
+ ```
200
+
201
+ ## API Reference
202
+
203
+ ### Core Methods
204
+
205
+ #### `LevelPlay.Init(string appKey, string userId = null)`
206
+ Initialize the LevelPlay SDK.
207
+
208
+ **Parameters:**
209
+ - `appKey`: Your application key from LevelPlay dashboard
210
+ - `userId` (optional): Your internal user ID for tracking and server-side reward verification
211
+
212
+ **Usage:**
213
+ ```csharp
214
+ // Basic initialization
215
+ LevelPlay.Init("your_app_key");
216
+
217
+ // With user ID
218
+ LevelPlay.Init("your_app_key", "user_12345");
219
+ ```
220
+
221
+ **Important:** Register `OnInitSuccess` and `OnInitFailed` callbacks before calling `Init()`.
222
+
223
+ **When to use user ID:**
224
+ - Server-side reward verification
225
+ - User-level analytics
226
+ - Cross-session tracking
227
+
228
+ #### `LevelPlay.SetSegment(LevelPlaySegment segment)`
229
+ Set user segmentation data for improved ad targeting and reporting.
230
+
231
+ **Parameters:**
232
+ - `segment`: A `LevelPlaySegment` object containing user segment information
233
+
234
+ **Usage:**
235
+ ```csharp
236
+ // Create a segment with user data
237
+ var segment = new LevelPlaySegment();
238
+ segment.SegmentName = "high_spenders";
239
+ segment.Level = 25;
240
+ segment.UserCreationDate = 1609459200000; // Unix timestamp in milliseconds (Jan 1, 2021)
241
+ segment.IapTotal = 49.99;
242
+ segment.IsPaying = 1; // 0 or 1
243
+
244
+ // Set custom parameters
245
+ segment.SetCustom("vip_tier", "gold");
246
+ segment.SetCustom("gameplay_hours", "150");
247
+
248
+ // Apply segment before or after initialization
249
+ LevelPlay.SetSegment(segment);
250
+ ```
251
+
252
+ **When to call:**
253
+ - Can be called before or after SDK initialization
254
+ - Update whenever user segment changes (level up, first purchase, etc.)
255
+ - Helps LevelPlay optimize ad delivery and reporting
256
+
257
+ **LevelPlaySegment properties:**
258
+ - `SegmentName` (string): Name of the segment (e.g., "high_spenders", "casual_players")
259
+ - `Level` (int): User's current level in the game
260
+ - `UserCreationDate` (long): Unix timestamp of when user created their account
261
+ - `IapTotal` (double): Total amount spent on in-app purchases
262
+ - `IsPaying` (int): Whether the user has made any purchases (0 or 1)
263
+
264
+ **LevelPlaySegment methods:**
265
+ - `SetCustom(string key, string value)`: Add custom key-value parameters for advanced segmentation
266
+
267
+ **Custom parameter limits:**
268
+ - Maximum 5 custom parameters per segment
269
+
270
+ **Best practices:**
271
+ - Update segments when significant user milestones occur
272
+ - Use meaningful segment names that describe user behavior
273
+ - Keep custom parameters descriptive and consistent
274
+ - Stay within the 5 custom parameter limit per segment
275
+
276
+ #### `LevelPlay.SetPauseGame(bool pause)`
277
+ Pause Unity 3D game activities (except ad callbacks) during ad presentation.
278
+
279
+ **Platform:** iOS only (SDK 8.5.0+)
280
+
281
+ **Parameters:**
282
+ - `pause`: Set to `true` to pause game activities during ads
283
+
284
+ **Usage:**
285
+ ```csharp
286
+ LevelPlay.SetPauseGame(true);
287
+ ```
288
+
289
+ **Notes:**
290
+ - iOS only
291
+ - Can be called once per session, before or after SDK initialization
292
+ - Game resumes automatically when ad closes
293
+ - Affects Rewarded and Interstitial ads
294
+
295
+ #### `LevelPlay.SetMetaData(string key, params string[] values)`
296
+ Set metadata for SDK configuration.
297
+
298
+ **Parameters:**
299
+ - `key`: The metadata key
300
+ - `values`: Array of values
301
+
302
+ **Use Cases:**
303
+
304
+ **1. Server-to-Server Rewarded Callbacks (SDK 8.11.0+)**
305
+
306
+ Pass custom parameters for rewarded ad callbacks:
307
+
308
+ ```csharp
309
+ LevelPlay.SetMetaData("LevelPlay_Rewarded_Server_Params", new [] { "key1=value1", "key2=value2" });
310
+ ```
311
+
312
+ **2. Test Suite Activation**
313
+
314
+ Enable the LevelPlay Test Suite:
315
+
316
+ ```csharp
317
+ LevelPlay.SetMetaData("is_test_suite", "enable");
318
+ LevelPlay.Init(appKey);
319
+ ```
320
+
321
+ **Note:** For Test Suite, must be called before `Init()`.
322
+
323
+ #### `LevelPlay.SetDynamicUserId(string userId)`
324
+ Set a dynamic user ID that can be changed during the session for server-side rewarded ad verification.
325
+
326
+ **Parameters:**
327
+ - `userId`: The dynamic user ID to set
328
+
329
+ **Returns:** `bool` - true if successfully set, false otherwise
330
+
331
+ **Usage:**
332
+ ```csharp
333
+ string newUserId = "user_67890";
334
+ bool success = LevelPlay.SetDynamicUserId(newUserId);
335
+ if (success)
336
+ {
337
+ Debug.Log($"Dynamic user ID set to: {newUserId}");
338
+ }
339
+ ```
340
+
341
+ **When to use:**
342
+ - Server-side reward verification for rewarded ads
343
+ - When user ID changes mid-session (e.g., user logs in after guest play)
344
+ - Must be set before showing rewarded ads that require verification
345
+
346
+ **Important:** This is different from the userId passed to `Init()`. The dynamic user ID can be changed during the session and is used specifically for server-to-server reward callbacks.
347
+
348
+ #### `LevelPlay.LaunchTestSuite()`
349
+ Launch the LevelPlay Test Suite for testing ad integrations on device.
350
+
351
+ **Usage:**
352
+ ```csharp
353
+ void OnInitSuccess(LevelPlayConfiguration config)
354
+ {
355
+ Debug.Log("SDK initialized");
356
+
357
+ #if UNITY_EDITOR || DEVELOPMENT_BUILD
358
+ // Launch Test Suite for testing
359
+ LevelPlay.LaunchTestSuite();
360
+ #endif
361
+ }
362
+ ```
363
+
364
+ **Requirements:**
365
+ - SDK must be initialized before calling this method
366
+ - Test Suite must be enabled via metadata before initialization:
367
+ ```csharp
368
+ LevelPlay.SetMetaData("is_test_suite", "enable");
369
+ LevelPlay.Init(appKey);
370
+ ```
371
+
372
+ **When to use:**
373
+ - Testing ad networks on real devices
374
+ - Verifying ad fill and display for different networks
375
+ - Debugging ad integration issues
376
+ - QA testing before release
377
+
378
+ **Notes:**
379
+ - Opens a UI overlay with test controls
380
+ - Allows testing each ad network individually
381
+ - Only available on device builds (not Editor)
382
+ - Should be removed or disabled in production builds
383
+
384
+ #### `LevelPlay.SetAdaptersDebug(bool enabled)`
385
+ Enable or disable debug logging for ad network adapters.
386
+
387
+ **Parameters:**
388
+ - `enabled`: Set to `true` to enable adapter debug logs, `false` to disable
389
+
390
+ **Usage:**
391
+ ```csharp
392
+ void Awake()
393
+ {
394
+ #if UNITY_EDITOR || DEVELOPMENT_BUILD
395
+ // Enable adapter debug logs for development
396
+ LevelPlay.SetAdaptersDebug(true);
397
+ #endif
398
+
399
+ LevelPlay.OnInitSuccess += OnInitSuccess;
400
+ LevelPlay.Init(appKey);
401
+ }
402
+ ```
403
+
404
+ **When to use:**
405
+ - Debugging ad network integration issues
406
+ - Investigating ad load failures
407
+ - Understanding adapter behavior
408
+ - Development and QA testing
409
+
410
+ **Notes:**
411
+ - Increases console log verbosity
412
+ - Helps diagnose network-specific issues
413
+ - Should be disabled in production builds
414
+ - Can be called before or after SDK initialization
415
+
416
+ #### `LevelPlay.SetNetworkData(string networkKey, string networkData)`
417
+ Set custom data for specific ad networks.
418
+
419
+ **Parameters:**
420
+ - `networkKey`: The ad network identifier (e.g., "UnityAds", "AdMob")
421
+ - `networkData`: Custom data string for the network
422
+
423
+ **Usage:**
424
+ ```csharp
425
+ // Set custom network-specific configuration
426
+ LevelPlay.SetNetworkData("UnityAds", "customValue");
427
+ LevelPlay.SetNetworkData("AdMob", "extraConfig");
428
+ ```
429
+
430
+ **When to use:**
431
+ - Passing custom configuration to specific ad networks
432
+ - Advanced network-specific setup
433
+ - When network adapter requires additional data
434
+
435
+ **Notes:**
436
+ - Call before SDK initialization
437
+ - Consult individual network adapter documentation for supported data
438
+ - Not commonly needed for standard integrations
439
+
440
+ ### Events
441
+
442
+ #### `LevelPlay.OnInitSuccess`
443
+ Fired when SDK initialization completes successfully.
444
+
445
+ **Signature:** `event Action<LevelPlayConfiguration>`
446
+
447
+ **Usage:**
448
+ ```csharp
449
+ LevelPlay.OnInitSuccess += (config) =>
450
+ {
451
+ Debug.Log("SDK ready");
452
+ Debug.Log($"Unity Version: {LevelPlay.UnityVersion}");
453
+ Debug.Log($"Plugin Version: {LevelPlay.PluginVersion}");
454
+ // Create ad objects here
455
+ };
456
+ ```
457
+
458
+ **Note:** `UnityVersion` and `PluginVersion` are static properties on the `LevelPlay` class, not on `LevelPlayConfiguration`.
459
+
460
+ #### `LevelPlay.OnInitFailed`
461
+ Fired when SDK initialization fails.
462
+
463
+ **Signature:** `event Action<LevelPlayInitError>`
464
+
465
+ **Usage:**
466
+ ```csharp
467
+ LevelPlay.OnInitFailed += (error) =>
468
+ {
469
+ Debug.LogError($"Init failed: Code {error.ErrorCode}, Message: {error.ErrorMessage}");
470
+ // Optionally retry
471
+ };
472
+ ```
473
+
474
+ **LevelPlayInitError properties:**
475
+ - `error.ErrorCode`: Numeric error code
476
+ - `error.ErrorMessage`: Description of the initialization error
477
+
478
+ ## Initialization Timing
479
+
480
+ ### Early Initialization (Recommended)
481
+
482
+ Initialize in your first scene, as early as possible:
483
+
484
+ ```csharp
485
+ void Awake()
486
+ {
487
+ DontDestroyOnLoad(gameObject);
488
+
489
+ LevelPlay.OnInitSuccess += OnInitSuccess;
490
+ LevelPlay.OnInitFailed += OnInitFailed;
491
+ LevelPlay.Init(appKey);
492
+ }
493
+ ```
494
+
495
+ **Why:** Ads start loading immediately, maximizing availability when needed.
496
+
497
+ ### Delayed Initialization (Advanced)
498
+
499
+ In some cases, you might delay initialization:
500
+
501
+ ```csharp
502
+ void Start()
503
+ {
504
+ // Wait for user to complete onboarding first
505
+ StartCoroutine(InitializeAfterOnboarding());
506
+ }
507
+
508
+ IEnumerator InitializeAfterOnboarding()
509
+ {
510
+ yield return new WaitUntil(() => HasCompletedOnboarding());
511
+
512
+ // Now initialize
513
+ LevelPlay.OnInitSuccess += OnInitSuccess;
514
+ LevelPlay.OnInitFailed += OnInitFailed;
515
+ LevelPlay.Init(appKey);
516
+ }
517
+ ```
518
+
519
+ **When to use:**
520
+ - Waiting for user consent decisions
521
+ - Completing critical onboarding first
522
+ - Reducing initial app load time
523
+
524
+ **Trade-off:** Ads won't be ready as quickly.
525
+
526
+ ## Best Practices
527
+
528
+ 1. **Initialize early**: Call `Init()` in your first scene's `Awake()` or `Start()`
529
+ 2. **Persist the initializer**: Use `DontDestroyOnLoad()` to prevent re-initialization
530
+ 3. **Register callbacks first**: Always register `OnInitSuccess` and `OnInitFailed` before calling `Init()`
531
+ 4. **Create ads after init**: Only create ad objects after `OnInitSuccess` fires
532
+ 5. **Set user ID if available**: Helps with analytics and server-side verification
533
+ 6. **Initialize only once**: Don't re-initialize the SDK across scenes
534
+ 7. **Handle failures**: Implement `OnInitFailed` to catch and log initialization errors
535
+
536
+ ## Testing
537
+
538
+ ### Development Checklist
539
+ - [ ] SDK initializes successfully (check logs)
540
+ - [ ] `OnInitSuccess` callback fires
541
+ - [ ] Ads can be created after initialization
542
+ - [ ] User ID is set correctly (if used)
543
+ - [ ] Initialization happens early in app lifecycle
544
+ - [ ] Error handling works (`OnInitFailed` implemented)
545
+
546
+ ### Common Issues
547
+
548
+ **Issue: Ads not loading after initialization**
549
+ - Check that App Key is correct
550
+ - Verify ad objects are created **after** `OnInitSuccess` fires
551
+ - Check console for initialization errors
552
+ - Enable test mode in LevelPlay dashboard
553
+
554
+ **Issue: Initialization fails**
555
+ - Verify App Key matches LevelPlay dashboard exactly
556
+ - Check internet connectivity
557
+ - Look at `LevelPlayInitError.ErrorMessage` for specific error
558
+ - Ensure LevelPlay SDK package is properly installed
559
+
560
+ **Issue: User ID not being tracked**
561
+ - Verify user ID is passed to `Init(appKey, userId)` as the second parameter
562
+ - Check that user ID is non-empty and unique
563
+ - Verify format meets LevelPlay requirements (alphanumeric, max 64 chars)
564
+
565
+ **Issue: Ads not ready when needed**
566
+ - Initialize earlier in the app lifecycle
567
+ - Create ad objects immediately in `OnInitSuccess`
568
+ - Load ads immediately after creating ad objects
569
+
570
+ ## Migration from IronSource.* APIs
571
+
572
+ If you're migrating from deprecated IronSource APIs:
573
+
574
+ **Old (Deprecated):**
575
+ ```csharp
576
+ IronSource.Agent.validateIntegration();
577
+ IronSource.Agent.init(appKey);
578
+ ```
579
+
580
+ **New (Current):**
581
+ ```csharp
582
+ LevelPlay.OnInitSuccess += OnInitSuccess;
583
+ LevelPlay.OnInitFailed += OnInitFailed;
584
+ LevelPlay.Init(appKey);
585
+ ```
586
+
587
+ **Key differences:**
588
+ - Init errors are reported via `OnInitFailed`; for integration validation use the LevelPlay Test Suite (`LaunchTestSuite()`)
589
+ - Must register callbacks before calling `Init()`
590
+ - Ad objects created explicitly after initialization (not automatic background loading)
591
+
592
+ ## Error Code Reference
593
+
594
+ When ad operations fail, `LevelPlayAdError` contains an `ErrorCode` property with one of these values:
595
+
596
+ | Code | Ad Formats | Description |
597
+ |------|-----------|-------------|
598
+ | **508** | N/A | Init failure of mediation/Network, Calling Demand Only API in non Demand Only mode, Calling non Demand Only API in Demand Only mode |
599
+ | **509** | Interstitial, Rewarded | Show Fail: No ads to show |
600
+ | **510** | Interstitial, Rewarded, Banner | Load Fail: Server response failed |
601
+ | **520** | Interstitial, Rewarded | Show Fail: No internet connection; ShouldTrackNetworkState is enabled |
602
+ | **524** | Interstitial, Rewarded | Show Fail: Placement has reached its limit as defined per pace or capping limit |
603
+ | **526** | Interstitial, Rewarded | Show Fail: Ad unit has reached its daily cap per session |
604
+ | **604** | Banner | Can't load because the placement is capped |
605
+ | **605** | Banner | Unexpected exception while loading the banner |
606
+ | **606** | Banner | No banner fill on all the networks on the first load |
607
+ | **1007** | Interstitial, Rewarded | Auction Fail: Auction request did not contain all required information |
608
+ | **1022** | Rewarded | Show Fail: Cannot show a rewarded ad while another rewarded ad is showing |
609
+ | **1023** | Rewarded | Show Fail: Show called when there are no available ads to show |
610
+ | **1035** | Interstitial | Empty Waterfall |
611
+ | **1036** | Interstitial | Show Fail: Cannot show an interstitial while another interstitial is showing |
612
+ | **1037** | Interstitial | Load Fail: Cannot load an interstitial while another interstitial is loading |
613
+
614
+ **Usage in error callbacks:**
615
+ ```csharp
616
+ private void OnAdLoadFailed(LevelPlayAdError error)
617
+ {
618
+ Debug.LogWarning($"Ad load failed: Code {error.ErrorCode}, Message: {error.ErrorMessage}");
619
+
620
+ // Handle specific errors
621
+ if (error.ErrorCode == 510)
622
+ {
623
+ // Server response failed - retry with backoff
624
+ }
625
+ else if (error.ErrorCode == 520)
626
+ {
627
+ // No internet connection - wait for connectivity
628
+ }
629
+ }
630
+ ```