t1k:unity:optimize:web-portal-publish
| Field | Value |
|---|---|
| Module | optimize |
| Version | 2.35.6 |
| Effort | high |
| Tools | — |
Keywords: audio streaming, duplicate dependencies, html5, i18n.lang, jenkins zip, language detection, media session, now playing, platformsetup, playables, playgama, portal zip, publish to yandex games, release/webgl, system player, tiktok, tiktok gaming, tiktok minigame, web platform release, web portal, web portal publish, webgl audio, yandex 1.6, yandex 2.14, yandex games, yandex zip not found, youtube playables
How to invoke
Section titled “How to invoke”/t1k:unity:optimize:web-portal-publish[yandex|tiktok|youtube] [resume|status|phase <0-6>] [--dry-run]t1k:unity:optimize:web-portal-publish — publish a mobile game to a web game portal
Section titled “t1k:unity:optimize:web-portal-publish — publish a mobile game to a web game portal”Seven phases, in this order. Each phase is idempotent and has a Done when check. resume (and
status) evaluate every Done when top-down and start at the first one that fails. Stop at every
STOP marker and hand over to the user — never fake a human step.
Unity root = the folder holding Assets/ and ProjectSettings/ (may be a subfolder of the git
root). Paths below are relative to it. <Project> = its folder name. Git ops go through /t1k:git;
never commit on the default branch. Do the conversion on a dedicated branch — it removes mobile SDKs.
Scope vs the web module. This skill is the portal-release pipeline for TheOne’s stack
(release/webgl submodules, com.theone.platformsetup, Yandex/TikTok/YouTube routes, Initial Bundle).
Porting mobile-only code to web adapters → t1k:unity:web:convert; a generic Web build/hosting
contract → t1k:unity:web:build; post-deploy browser checks → t1k:unity:web:validate.
Global guardrails (apply to every phase)
Section titled “Global guardrails (apply to every phase)”- One session drives the Editor. Confirm no sibling session holds it (mutating
t1k unityverbs exit 10 when the project lock is busy) and thatmeta.projectRootfromt1k unity statusis this project before trusting any result. - Before any domain reload (target switch, branch checkout, manifest edit, refresh): Editor idle
(
pgrep -cf "AssetImportWorker.*<Project>"≤ 2 idle pool workers,t1k unity statusreports the Editor ready) and not in Play mode. One refresh at a time. - Never kill/restart/quit the Editor, never
Assets/Reimport All. - Never edit
Packages/**, submodules (.gitmodules) orLibrary/PackageCache/**to fix errors — fix game code, or open an upstream PR in the submodule’s own repo. - A
t1k unity refresh/recompilethat reports no compile having run means stale, not clean. A massCS0246cascade → read the UPM log for an auth error first. - A clean console is not evidence (Flatpak Hub can return 0 entries). Confirm with the live
Editor.log(counterror CSafter the lastReloading assemblies) and the assembly mtime. - Run long Editor jobs synchronously through
t1k unity eval(blocking), notEditorApplication.delayCall: delayCall never fires while the Editor window is unfocused (observed: a job sat idle 10 min). - Preview-first: show a dry-run/diff and
AskUserQuestionbefore every manifest mutation, the real PlatformSetup Install, any regroup, and any deletion. - Ship every WebGL build with
webGLDecompressionFallback: 1. The build CDN, Yandex and Playgama do not all sendContent-Encoding: br, and a build compressed without the fallback hangs on the splash withUnable to parse …<hash>.framework.js.br. Verify per build:grep webGLDecompressionFallback ProjectSettings/ProjectSettings.asset→1, and the outputBuild/folder holds.unityweb, not.br. Detail:references/yandex-route.mdstep 7.
Phase 0 — Choose the target platform
Section titled “Phase 0 — Choose the target platform”If the argument names a platform, use it. Otherwise AskUserQuestion (single select):
Yandex Games · TikTok Gaming · YouTube Playables. Record the choice; every later phase and
resume reuse it (re-ask only if it cannot be recovered from the session or the project’s defines:
PLAYGAMA_BRIDGE → Yandex, TIKTOK_MINIGAME → TikTok, YOUTUBE_PLAYABLES → YouTube).
Support level in PlatformSetup 2.2.6 — tell the user before continuing:
| Platform | PlatformSetup Install does | Route file |
|---|---|---|
| Yandex Games | Full: removes mobile SDKs, adds Playgama Bridge + defines + asmdef refs, seeds loading scope | references/yandex-route.md |
| TikTok Gaming | Placeholder: seeds the loading scope only; everything else is manual and has known blockers. Needs Unity 2021/2022 (SDK limit) and so the com.gdk.core release/tiktok branch, not release/webgl | references/tiktok-route.md |
| YouTube Playables | Placeholder: seeds the loading scope only; everything else is manual and has known blockers | references/youtube-route.md |
Done when: a platform is chosen and the user has seen its support level.
Phase 1 — Build profile → WebGL
Section titled “Phase 1 — Build profile → WebGL”- Read the active target (
t1k unity eval 'EditorUserBuildSettings.activeBuildTarget'; the facade has no build verb). Already WebGL → skip. - Switch to WebGL (
t1k unity eval 'EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL)', unverified live). Wait for the reload (30–180 s; exit 7 during it is normal — wait fort1k unity status, retry, don’t escalate).
Done when: activeBuildTarget reports WebGL.
Phase 2 — Submodules → release/webgl
Section titled “Phase 2 — Submodules → release/webgl”- TikTok route: use
release/tiktokofcom.gdk.coreinstead (Unity 2022 compatible; seereferences/tiktok-route.mdblocker 3). A submodule fix always lands in the submodule’s own repo on a new branch, pushed before the parent pointer is bumped. - From the repo-root
.gitmodules, pick the studio submodules that have arelease/webglbranch (git -C <path> ls-remote --heads origin release/webgl); typicallyPackages/com.gdk.core,Packages/com.gdk.3rd,Assets/UITemplate. - For each:
git -C <path> fetch origin && git -C <path> checkout release/webgl && git -C <path> pull --ff-only. A dirty submodule → STOP and diagnose (below); never stash/discard silently. - Commit the pointer bumps in the parent via
/t1k:git.
Dirty after the move — check for a duplicated plugin. If a submodule shows .meta files whose
only change is guid:, the same asset now exists twice (e.g. release/webgl com.gdk.core ships
Odin’s generated Plugins/Sirenix/Odin Inspector/{Assets,Modules} while the project keeps its own
copy in Assets/Plugins/Sirenix/Odin Inspector). Unity rewrote the package’s GUIDs. Diff the two
file sets, AskUserQuestion which copy wins (default: keep the package’s), delete only the duplicated
files from the project copy (keep project-only config such as Config/), then
git -C <submodule> checkout -- <path> to restore the package GUIDs.
Done when: each submodule HEAD equals origin/release/webgl (detached is fine), it is clean, and
git submodule status shows no +.
Phase 3 — Fix all compile errors
Section titled “Phase 3 — Fix all compile errors”Loop: t1k unity refresh --compile (or t1k unity recompile, errors in data.errors[]) → errors
from t1k unity console --level error and Editor.log → group by root cause → fix the whole batch → repeat. After 3
loops that don’t reduce the count: STOP, report errors grouped by assembly, escalate
(t1k-kongming) — no 4th blind fix.
Common WebGL causes: a mobile SDK define still set for WebGL (fix with the right #if, or let the
platform installer strip it); APIs unavailable on WebGL (threads, System.IO writes, native plugins).
WebGL defines are a separate list — nothing is inherited from Android. scriptingDefineSymbols
in ProjectSettings/ProjectSettings.asset is keyed per build target, so a define set only on
Android (e.g. X_LOCALIZATION) is simply absent under WebGL. Every #if X_LOCALIZATION
block in com.gdk.core’s LocalizationHelper and UITemplate then compiles to its empty fallback:
the game builds, the console stays clean, and localization silently returns the raw entry keys.
A green compile does not cover this — check it explicitly. After the target switch, diff the WebGL
line against Android in ProjectSettings/ProjectSettings.asset and copy over every game define the
web build needs (X_LOCALIZATION, X_IAP, the other X_* game defines); treat a define present on Android
but missing on WebGL as a bug, not as a default. The platform installer does not do this for you — it
strips mobile defines, it never restores game ones.
Done when: a refresh with refresh_triggered: true yields zero errors in Editor.log after the
last reload, and the game assembly’s mtime is newer than the last source edit.
Phase 4 — Install com.theone.platformsetup 2.2.6
Section titled “Phase 4 — Install com.theone.platformsetup 2.2.6”Packages/manifest.jsonalready pins"com.theone.platformsetup": "2.2.6"→ skip.- Else ensure the scoped registry
TheOne(https://upm.the1studio.org/, scopecom.theone), add the dependency at exactly2.2.6, show the diff,AskUserQuestion, write, refresh. - Re-run the Phase 3 loop if the add introduced errors.
Done when: Library/PackageCache/com.theone.platformsetup@*/package.json reports 2.2.6.
Phase 5 — The platform route
Section titled “Phase 5 — The platform route”Run the route file chosen in Phase 0. All three share this shape:
- One writer on the branch; unexplained staged changes → ask.
- Loading screen: Install seeds
Assets/Scripts/Scenes/LoadingSceneScope.cs(packageLoadingScreenPresenter). If the project’s scope lives elsewhere,AskUserQuestion: keep the project’s, switch to the package’s, or decide later. - PlatformSetup Install: Dry-run → show report → confirm → Install → Verify.
- Compile loop; register the platform’s ads / storage / IAP in the game
LifetimeScope. Yandex rate-us needs a Playgama service, and ads “not loaded” /PlaygamaBridge not foundmeansPLAYGAMA_BRIDGEis missing from the build’s defines:references/playgama-store-rating.md. - GameReady / platform-ready call (STOP to confirm the hook point).
- Pause + mute on ad show and focus loss; locale from the platform.
Yandex 2.14 language detection (debug-panel 文 indicator):
references/yandex-language-detection.md. No system player (Yandex 1.6.1.6 / 1.6.2.5): every AudioClip must be Decompress On Load on WebGL. Streaming, and Compressed In Memory over 128 KB on iOS/Safari, play through an HTML<audio>element, and iOS then shows the game in “Now Playing” (Chrome hides this; test on an iPhone). Runscripts/webgl_audio_loadtype_check.py --project <UnityRoot>until it exits 0;--fix(optionally--sample-rate 22050for music, after asking the user about the memory trade-off):references/webgl-audio-system-player.md. - Compression (Brotli + Decompression Fallback — not optional, see
references/yandex-route.mdstep 7), texture formats, rebuild Addressables, WebGL build, zip (STOP — upload is the user’s). Building on Jenkins withPARAM_BUILD_YANDEX? Confirm the project has a WebGL zip postprocessor before the first run (Playgama games do not get one for free); “Yandex Games zip not found” →references/jenkins-portal-zip.md. - Store page + certification checklist — STOP; the user submits.
Driving the Install from code (the window is an Odin Hub, TheOne → Platform Setup): find the module
type by name (YandexPlatformSetupModule, TikTokPlatformSetupModule,
YouTubePlayablesPlatformSetupModule), Activator.CreateInstance, set the DryRun field, call
Install() / Verify(), capture Application.logMessageReceived. Dry-run shows no dialogs; the
real Yandex Install shows a “Confirm package removal” dialog only the user can click — schedule it
and tell the user to click, or let them press Install themselves.
Phase 6 — Initial Bundle + duplicate dependencies
Section titled “Phase 6 — Initial Bundle + duplicate dependencies”Analyze path of /t1k:unity:optimize:initial-bundle, merged here. Commands and a worked example:
references/initial-bundle.md.
- GameReady boundary = the hook confirmed in Phase 5 step 5 (don’t re-ask).
- Build Addressables synchronously, run the size script (
--project <UnityRoot> --budget-mib 30). - Run
CheckBundleDupeDependencies; any hit →FixIssues, force the newDuplicate Asset Isolationgroup to Pack Together, re-run until 0, rebuild, re-measure. - Report
group | MiB | why initial (label / dependency)and the total vs 30 MiB. - Regrouping into one
InitialBundle+ lazy-loading changes group assets that also ship on mobile branches → STOP,AskUserQuestionbefore any regroup. - Any Addressables change after the Phase 5 build makes the zip stale → rebuild player + zip.
Done when: duplicates = 0, the size report exists, and the user accepted or scheduled the regroup.
Output
Section titled “Output”End with: the chosen platform; a phase table phase | status (done/skipped/stopped) | evidence (command or file); the list of STOP items waiting on the user. No “done” without evidence.