unity/upms/webgl/readme.md
High Efficiency | 开发很快
Fast | 执行很快
with the JIT in browser's v8. Puer Webgl has a huge execute performance advantage.
因为在这套架构下,JS是运行在宿主JS环境下的,有JIT的支持,因此相比Lua脚本方案,在执行性能上有碾压性的性能优势。
| 100k fibonacci(12) | |
|---|---|
| xLua WebGL | 6200ms |
| Puerts WebGL | 165ms |
更深入的优化请参见: 这篇知乎文章
use demo project to know puerts-webgl | 利用demo项目了解PuerTS-WebGL
build directory. you can quickly try these 4 demo which is built by Unity2021.projects | 打开projects下的任意项目puerts-webgl/install in the Menu | 点击puerts-webgl/installPuerTS/TSLoader/Release TS to Resources because ts-loader is used | (除了Sample1)因为使用了ts-loader,需要点击PuerTS/TSLoader/Release TS to Resourcespuerts-webgl/build for browser following the tips by step3 in console | 根据第3步出现的命令行提示,点击puerts-webgl/build for browser将JS拷贝到构建目录
6。 append these code before </head> in index.html built by Unity: | 将下述代码放到index.html的</head>前 <script src="./puerts-runtime.js"></script>
<script src="./puerts_browser_js_resources.js"></script>
Install puerts first | 首先安装puerts本体 :
Install puerts-webgl | 安装PuerTS-WebGL支持:
<details> <summary>Add from OpenUPM | available in 2018+</summary>你可按照OpenUPM所支持的方式安装该包:https://openupm.com/packages/com.tencent.puerts.webgl/
</details> <details> <summary>Add from Git</summary>带有upm的unity版本,可以使用这种方式安装
https://github.com/Tencent/puerts.git+Add from FileAddInstall puerts-webgl-jsbuild(in first time) | 安装jsbuild组件(首次运行需要):
<details> <summary>Add from Git</summary>带有upm的unity版本,可以使用这种方式安装
https://github.com/zombieyang/puerts_unity_webgl_demo.git+Add from FileAddYou can also copy all the code into your Assets directory. But I don't recommend it.
Jsbuild is only for example, in most case you will need to customize it by yourself
你也可以将所有代码都复制到你的Assets目录,但我不建议这么做
Jsbuild包基本只用于示例,大部份情况下最终你都需要自己定制jsbuild代码,因此目前也没有把jsbuild传到openupm
Unable to parse Build/H5.framework.js.gz! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: gzip" present. Check browser Console and Devtools Network tab to debug.
Player Settings > Publish Settings > Compression Format to Disabled. delete your previous build and rebuild.Player Settings > Publish Settings > Compression Format 设为 Disabled。删掉你上一次的构建产物,然后重新构建。Player Settings > Publishing Settings > Compression Format to DisabledQQ群:942696334