UnityPlugin Usage Guide
# UnityPlugin Usage Guide
# Version Requirements
Unity requires SDK version 2.44.9 To integrate the Extension SDK: implementation 'com.finogeeks.mop:plugins:2.44.9'
Base Library version 3.3.5 or higher
# How to Use
Unity Mini-Games use a UnityPlugin from the WeChat platform
This Plugin cannot be directly downloaded on the FinClip platform
Therefore, we provide a replacement solution here, using plugin version 1.2.45 as an example:
First, pull the code of the plugin corresponding to the Mini-Game version (when opening the Unity Mini-Game in WeChat Developer Tools, you can view the source and obtain the corresponding code). After processing with babel.js, it will output a plugin code directory.
After obtaining the plugin code, there are two replacement methods:
- Replace the
requirePluginin the Unity Mini-Gamegame.jswith a local reference method
Original Mini-Game code:
// game.js
UnityManager = requirePlugin('UnityPlugin', {
enableRequireHostModule: true,
customEnv: {
wx,
unityNamespace,
document,
canvas,
events: GameGlobal.events,
WXWASMSDK: GameGlobal.WXWASMSDK,
},
}).default;
Replace with:
GameGlobal.unityNamespace = unityNamespace
GameGlobal.customEnv = {
wx,
unityNamespace,
document,
canvas,
events: GameGlobal.events,
WXWASMSDK: GameGlobal.WXWASMSDK,
}
GameGlobal.pluginEnv = {
isMiniGamePlugin: true,
coverview: wx.coverview || {
Component: function () {},
getPrivateThis: function () {
return {
loadingText: {},
loadPromise: Promise.resolve()
}
}
},
customEnv: GameGlobal.customEnv,
gameTransfer() {}
}
// Point to the plugin directory of the local project
UnityManager = require('./plugin/dist/index', {
enableRequireHostModule: true,
customEnv: {
wx,
unityNamespace,
document,
canvas,
events: GameGlobal.events,
WXWASMSDK: GameGlobal.WXWASMSDK,
},
}).default;
- Upload the plugin to the FinClip platform, then replace the plugin ID and version
Original Mini-Game game.json code:
"plugins": {
"UnityPlugin" : {
"version" : "1.2.45",
"provider" : "wxe5a48f1ed5f544b7",
"contexts" : [
{
"type" : "isolatedContext"
}
]
}
},
Replaced Mini-Game game.json code:
"plugins": {
"UnityPlugin" : {
"version" : "1.2.4501", // For display only, actual version number and ID need to be determined after plugin upload
"provider" : "66308aed2c3c9800019e83b2",
"contexts" : [
{
"type" : "isolatedContext"
}
]
}
},
Currently, Solution 1 only requires replacing the local plugin to run
Solution 2 requires uploading the plugin to the corresponding environment. You can first verify with Solution 1; Solution 2 requires specific compilation library versions
# Plugin Upload Instructions
This directory is a Studio plugin project directory
You can directly open this directory with Studio, then select Upload, and choose the plugin ID in the environment and fill in the version number

Note that in fide.project.config.json, "pluginRoot" indicates the entry directory of the current plugin
For example, "pluginRoot": "1.2.38/dist" means using version 1.2.38. When uploading plugins of other versions, you can modify this field to other version folders
Notes:
This plugin project is only used for uploading and cannot execute plugin code, so Studio will report plugin errors, but this does not affect uploading
When uploading, uncheck "es6 to es5" in the details, because the plugin itself has been compiled and processed and does not need further conversion
It is recommended to modify the plugin version number to match the WeChat plugin version number when uploading, for example: for plugin version 1.2.45, fill in version number 1.2.45 or 1.2.451 when uploading