Development Environment

  • Unity Engine Version: 1.6.2 Professional Edition
  • Project Environment: Unity 1.62 + Instant Game (AutoStreaming) + Addressable

Preparation Steps

1. Switch to Minigame Mode

First, switch to Minigame mode, then switch to the Douyin development environment.

Important Note: After switching, there's no need to change StartSDK to TTSDK within ByteGame—the TTSDK environment is the default.

Critical Distinction: This differs from Unity's traditional WebGL build and conversion process. Pay careful attention to this difference.

2. Prepare Douyin Developer Tools

Download Page: Douyin Developer Tools Download

Login Troubleshooting: If unable to log into Douyin Developer Tools, change your network connection DNS to manual configuration:

  • Primary DNS: 114.114.114.114
  • Secondary DNS: 8.8.8.8

3. TTSDK Initialization

Functional Capabilities Overview

1. Sidebar

Documentation: Sidebar API Reference

2. Sharing

Sharing functionality includes success and failure callbacks, differing from WeChat's implementation.

Important: Sharing materials can only be submitted in the Douyin backend after you submit your version.

Documentation: Sharing Module

3. Rewarded Video Ads

Before creating a video ad, clear previous cache:

ad.Destroy();

Then wait several frames before recreating.

Asynchronous Frame Wait: Use await Task.Yield(); — do NOT use await Task.Delay(1);

Documentation: Rewarded Video Ads

4. Add to Desktop

This feature behaves somewhat mysteriously. Similar to JD.com, it may require iOS differentiation. Note that UNITY_IOS may not take effect on mini-games. Refer to differentiation methods from previous articles. If unavailable, try switching SDK name prefixes.

Documentation: Add to Desktop

5. Publisher Plan

This relates to user acquisition—no technical implementation details required.

6. Subscription

Requires corresponding operational functionality activation.

Documentation: Subscription Introduction

7. New Game Cold Start

No example provided—not implemented in this project.

8. Live Streaming Companion Game Launch

Not implemented in this project.

9. Recommended Feed Game Instant Play

Not implemented in this project.

10. Interstitial Ads

Also known as "full-screen interstitial," displays an advertisement in the center of the screen.

Documentation: Interstitial Ads

11. Rewarded Video Ads (IAA Industry)

For IAA (In-App Advertising) industry, there's no need to focus on eCPM values and callbacks. For money-making industry, no example content provided here—requires personal data debugging.

Recommendation: Use multiple IDs for random switching, 3-5 IDs sufficient.

Documentation: Incentive Ads

Packaging Process

This example uses Unity Engine + Instant Game (AutoStreaming) + Addressable configuration.

1. Minigame Platform vs Traditional WebGL

We're using the Minigame platform here, not traditional WebGL. While both ultimately produce WebGL output, the operational processes differ significantly.

Douyin Documentation: Unity Game Access Flow

2. Unity Official Documentation

Critical Point: Unlike WeChat mini-games, Douyin mini-games do not provide conversion options.

3. Address Configuration Challenge

The Instant Game UOS CDN address won't be automatically taken over by Addressable. Manual adjustment of Addressables Profiles' Remote.LoadPath address is required.

Problem: Adjusting this frequently causes errors, and project references may display placeholder addresses like https://dummy.dummy.dummy/.

4. Solution: Script-Based Address Replacement

Create a script in your project with the [Preserve] attribute. No need to mount the script on any object—simply place it in the project.

Add the method shown in the reference diagram to replace placeholder addresses with the CDN address. Ensure a trailing slash follows "content."

No Addressables Profiles Adjustment Required.

5. Build Process

  1. First, fill in Douyin Profile information
  2. After completion, directly build the package
  3. The build output contains Douyin-uploadable content

6. Douyin Profile Configuration

Required Douyin Profile information includes various settings. If underlying information isn't visible, click a "Custom" option to expand additional fields.

7. Final Build

Click build to complete the packaging process successfully.

8. URL Whitelist Configuration

Important: Douyin mini-games require URL whitelist configuration, similar to WeChat. However, remove the https:// prefix from URLs. JD mini-games do not require whitelists.

Key Takeaways

Successfully deploying Douyin mini-games requires careful attention to several critical differences from traditional Unity WebGL builds:

  1. Platform Selection: Always use Minigame mode, not traditional WebGL
  2. Address Configuration: Manual CDN address replacement is necessary
  3. Script Preservation: Use [Preserve] attribute for address replacement scripts
  4. URL Formatting: Remove https:// prefix for whitelist entries
  5. SDK Defaults: TTSDK is automatically selected after environment switching

Following this guide should help you avoid the countless pitfalls encountered during the learning process. Each step has been verified through actual deployment experience, ensuring reliable results when properly followed.