bilibili Toy
bilibili Toy runs a game as a web page inside the Toy container. Pygame Studio produces that page and, when bilibili Toy is picked as the publishing platform, puts the SDK bridge the game code needs into the package.
An example already online: Just Eat 100 Apples
- Open Project → Build (
Ctrl+B) and switch to the Web App tab. - Fill in App Name, App Icon and Output Dir as usual.
- Set Publishing Platform to bilibili Toy.
- Click Build and check the result in the Console.
Output:
<Output Dir>/build/Web/├─ index.html the page (loads the runtime, shows progress and errors)├─ game.data the protected project + the engine├─ pyodide/ folder holding the game's runtime dependencies└─ favicon.ico the browser tab iconToy platform adaptation
Section titled “Toy platform adaptation”The container only serves a fixed set of file types, so the build reorganises the bundle for it:
- archives are renamed from
.zipto.data(game.data,python_stdlib.data) and every wheel from.whlto.data; - the Pyodide runtime is patched so it loads those names, and every
.mjsfile is removed; - the platform script
<script src="//s1.hdslb.com/bfs/seed/toy/app/sdk/toy-sdk.js">is added toindex.html, which putswindow.toyon the page; - before finishing, every file is checked against the whitelist and the build stops with an error as soon as something the container would drop is still there.
Allowed file types (anything else fails the build):
| Kind | Extensions |
|---|---|
| Pages, code, data | .html .htm .css .js .json .wasm .data .md .csv .tsv |
| Images | .png .jpg .jpeg .gif .svg .webp .ico |
| Fonts | .woff2 .woff .ttf .eot |
| Audio and video | .mp3 .wav .ogg .m4a .mp4 .webm |
Use the Toy SDK
Section titled “Use the Toy SDK”The container injects the platform’s JavaScript SDK, and the engine’s code editor reaches it through studio.sdk.toy. Call available() first to check whether the game is running inside a Toy container.
import pygamestudio as studio
class ObjectScript: def __init__(self, obj): self.obj = obj
def on_start(self): toy = studio.sdk.toy if not toy.available(): return toy.get_user_profile().then( lambda user: self.obj.set_text('Hi, ' + user['nickname']) )The other calls are listed under bilibili Toy SDK — sharing, cloud storage, scores, QR codes, camera and microphone, input safety and more.
Publish
Section titled “Publish”-
Compress the built files into an archive.

-
Open the bilibili Toy site and click the publish button in the top right corner.

-
Upload the archive, fill in the rest of the game information and publish — the game goes live once it passes review.

Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause and fix |
|---|---|
| The build stops with These files are not supported by Bilibili Toy and would be dropped… | An asset uses an extension outside the whitelist. Convert or remove it, then build again. |
ToyUnavailableError in the browser | The page is not inside the Toy container (opened locally, for example). Expected outside the platform — check with toy.available(). |
| A sound or image does not show in the container | Its file type is not on the whitelist and the platform dropped it. |