Skip to content

t1k:unity:optimize:web-portal-publish

FieldValue
Moduleoptimize
Version2.35.6
Efforthigh
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

/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.

  • One session drives the Editor. Confirm no sibling session holds it (mutating t1k unity verbs exit 10 when the project lock is busy) and that meta.projectRoot from t1k unity status is 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 status reports 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) or Library/PackageCache/** to fix errors — fix game code, or open an upstream PR in the submodule’s own repo.
  • A t1k unity refresh / recompile that reports no compile having run means stale, not clean. A mass CS0246 cascade → 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 (count error CS after the last Reloading assemblies) and the assembly mtime.
  • Run long Editor jobs synchronously through t1k unity eval (blocking), not EditorApplication.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 AskUserQuestion before 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 send Content-Encoding: br, and a build compressed without the fallback hangs on the splash with Unable to parse …<hash>.framework.js.br. Verify per build: grep webGLDecompressionFallback ProjectSettings/ProjectSettings.asset → 1, and the output Build/ folder holds .unityweb, not .br. Detail: references/yandex-route.md step 7.

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:

PlatformPlatformSetup Install doesRoute file
Yandex GamesFull: removes mobile SDKs, adds Playgama Bridge + defines + asmdef refs, seeds loading scopereferences/yandex-route.md
TikTok GamingPlaceholder: 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/webglreferences/tiktok-route.md
YouTube PlayablesPlaceholder: seeds the loading scope only; everything else is manual and has known blockersreferences/youtube-route.md

Done when: a platform is chosen and the user has seen its support level.

  1. Read the active target (t1k unity eval 'EditorUserBuildSettings.activeBuildTarget'; the facade has no build verb). Already WebGL → skip.
  2. 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 for t1k unity status, retry, don’t escalate).

Done when: activeBuildTarget reports WebGL.

  1. TikTok route: use release/tiktok of com.gdk.core instead (Unity 2022 compatible; see references/tiktok-route.md blocker 3). A submodule fix always lands in the submodule’s own repo on a new branch, pushed before the parent pointer is bumped.
  2. From the repo-root .gitmodules, pick the studio submodules that have a release/webgl branch (git -C <path> ls-remote --heads origin release/webgl); typically Packages/com.gdk.core, Packages/com.gdk.3rd, Assets/UITemplate.
  3. 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.
  4. 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 +.

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”
  1. Packages/manifest.json already pins "com.theone.platformsetup": "2.2.6" → skip.
  2. Else ensure the scoped registry TheOne (https://upm.the1studio.org/, scope com.theone), add the dependency at exactly 2.2.6, show the diff, AskUserQuestion, write, refresh.
  3. Re-run the Phase 3 loop if the add introduced errors.

Done when: Library/PackageCache/com.theone.platformsetup@*/package.json reports 2.2.6.

Run the route file chosen in Phase 0. All three share this shape:

  1. One writer on the branch; unexplained staged changes → ask.
  2. Loading screen: Install seeds Assets/Scripts/Scenes/LoadingSceneScope.cs (package LoadingScreenPresenter). If the project’s scope lives elsewhere, AskUserQuestion: keep the project’s, switch to the package’s, or decide later.
  3. PlatformSetup Install: Dry-run → show report → confirm → Install → Verify.
  4. 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 found means PLAYGAMA_BRIDGE is missing from the build’s defines: references/playgama-store-rating.md.
  5. GameReady / platform-ready call (STOP to confirm the hook point).
  6. 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). Run scripts/webgl_audio_loadtype_check.py --project <UnityRoot> until it exits 0; --fix (optionally --sample-rate 22050 for music, after asking the user about the memory trade-off): references/webgl-audio-system-player.md.
  7. Compression (Brotli + Decompression Fallback — not optional, see references/yandex-route.md step 7), texture formats, rebuild Addressables, WebGL build, zip (STOP — upload is the user’s). Building on Jenkins with PARAM_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.
  8. 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.

  1. GameReady boundary = the hook confirmed in Phase 5 step 5 (don’t re-ask).
  2. Build Addressables synchronously, run the size script (--project <UnityRoot> --budget-mib 30).
  3. Run CheckBundleDupeDependencies; any hit → FixIssues, force the new Duplicate Asset Isolation group to Pack Together, re-run until 0, rebuild, re-measure.
  4. Report group | MiB | why initial (label / dependency) and the total vs 30 MiB.
  5. Regrouping into one InitialBundle + lazy-loading changes group assets that also ship on mobile branches → STOP, AskUserQuestion before any regroup.
  6. 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.

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.